Skip to content

CLI: scan command with piped stdout may emit 'too many arguments' error #24

Description

@jonathansantilli

Description

When running codegate scan with a URL target, certain combinations of flags and stdout piping produce an intermittent error: too many arguments for 'scan'. Expected 1 argument but got 2. error from Commander.js.

Steps to Reproduce

# This works:
codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui --output /tmp/report.json

# This intermittently fails:
codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui | tee /tmp/report.json

The error does not reproduce when:

  • Using --output <file> instead of piping stdout
  • Running without tee or other pipe consumers
  • Running with fewer flags (e.g., --deep alone or --force alone works)

Investigation Notes

  • Commander.js argument parsing is correct — a minimal reproduction with createCli() and overridden action handler parses all arguments correctly (target, --deep, --force, --format json, --no-tui).
  • The error seems related to stdout piping changing process.stdout.isTTY from true to false, which may affect code paths downstream of argument parsing.
  • The --no-tui option uses Commander's --no-* negation pattern, which creates an implicit --tui boolean. This could interact unexpectedly with TTY detection.

Where to Look

  • src/cli.tsaddScanCommand() function (~line 383), specifically the .command("scan [target]") definition and how isNoTuiEnabled() interacts with the action handler
  • The interplay between --no-tui, deps.isTTY(), and Commander's argument parsing when stdout is not a TTY

Workaround

Use the --output <path> flag to write reports to a file instead of piping stdout:

codegate scan "https://github.com/owner/repo" --deep --force --format json --no-tui --output /tmp/report.json

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions