Skip to content

[bug] tags add overwrites a tags.yaml it cannot read, and tag refusals exit 0 #2046

Done

Description

@Kiko0301

Description

Two ways a tag command mishandles a tags.yaml it cannot read:

  1. teamai tags add replaces the file with a new one holding only the tags just added, silently dropping every tag the team had.
  2. teamai tags remove and the empty-tag refusals print ✖ but exit 0, so a script or CI job reads the refusal as success.

Steps to reproduce

On main at 6911c22 (Windows 11, Node v22.19.0), in a project whose team repo holds a malformed tags.yaml:

$ printf 'skills: [unclosed\n' > team/tags.yaml
$ teamai tags add skills deploy backend
⚠ Failed to parse tags.yaml: Flow sequence in block collection must be sufficiently indented and end with a ] ...
✔ Set skills/deploy tags: backend
$ cat team/tags.yaml
skills:
  deploy:
    - backend
rules: {}

The old tag table is gone. A tags.yaml whose document is a scalar (just-a-scalar) is even quieter: loadTagsConfig returns null without a warning, and tags add still overwrites it.

$ teamai tags remove skills deploy backend      # team repo has no tags.yaml
✖ No tags.yaml found in team repo.
$ echo $?
0

Expected

  • tags add refuses when tags.yaml exists but does not parse, naming the file and leaving it byte-for-byte unchanged.
  • tags remove says the file could not be read (not that it is missing) and exits 1 on that refusal, and also exits 1 when the file is missing.
  • The empty-tag refusals in tags subscribe, tags unsubscribe, tags add and tags remove exit 1, as the other tag refusals in the same command already do (tags remove on an unknown tag is a no-op, not a refusal).
  • tags list is unchanged in this issue.

Cause

  • loadTagsConfig (src/utils/tags.ts) returns null both for a missing file and for one that does not parse; tagsAdd treats null as "start a new file", so it writes over the unreadable one.
  • The refusal paths in src/tags.ts call log.error(...) and return without setting process.exitCode.

Fix

  • In tagsAdd, when the load returns null and tags.yaml exists, report that it could not be read and stop with exit 1; only a missing file starts a new table.
  • In tagsRemove, distinguish "could not be read" from "not found" with pathExists, and set exit 1.
  • Set process.exitCode = 1 on the empty-tag refusals.

Environment

  • OS: Windows 11 (build 26100), Git Bash
  • Node.js: v22.19.0
  • teamai: built from 6911c22
  • Provider: git

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions