Skip to content

Invalid --output value is silently coerced to text in auth/usage/agent/init (should exit 5) #13

Description

@Davidson3556

Summary

The global --output flag is validated inconsistently across command groups. test and project reject an unrecognised value with a typed VALIDATION_ERROR (exit 5), but auth, usage, agent, and init silently coerce anything that isn't json/text to text mode via globals.output ?? 'text'.

Why it matters

The CLI's primary consumer is a coding agent. If an agent asks for --output json but mistypes it (--output josn), four of the six command groups hand back a human-readable text payload, exit 0, and the agent's JSON.parse fails downstream with no signal as to the cause.

Reproduction

$ testsprite --output josn agent list      # silently prints a text table, exits 0
$ testsprite --output josn test list ...    # correctly exits 5 with a clear error

Expected: every command group rejects an invalid --output value with exit 5 and an actionable message.

Secondary issue

Even among the commands that do validate, the wording diverges:

  • test: Flag `--output` is invalid: must be one of: json, text.
  • project: --output must be one of: json, text

These should be unified.

Suggested fix

Extract a shared resolveOutputMode(raw): OutputMode helper in src/lib/output.ts that returns 'text' for an omitted flag and throws localValidationError('output', 'must be one of: json, text', ['json','text']) otherwise, then route every command group's resolveCommonOptions through it.

I have a PR ready for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions