Skip to content

An unknown -o value is accepted and silently writes JSONL #133

Closed

Description

@tamnd
$ ccrawl rank top -n 1 -o bogus; echo $?
{"key":"www.facebook.com","harmonic_pos":1,...}
0

-o takes auto|table|markdown|list|json|jsonl|csv|tsv|url|raw|parquet. Anything else is not refused, it is rendered as JSONL with exit 0, so ccrawl search example.com -o csvv > captures.csv leaves a file of JSON lines named .csv and says nothing went wrong.

Where it goes wrong

It is the framework, not ccrawl. kit/render.Renderer.Emit dispatches on the format and ends:

default:
    return r.emitJSONL(jsonValue(rec))

Nothing rejects the value on the way in either, so the typo survives all the way to the encoder and falls off the end of the switch.

The right fix is upstream in any-cli: reject an unknown format when the renderer is built, the same way an unknown --color or --progress value would be. RegisteredFormats already exists, so the valid set is known at that point.

The local workaround, and why it is not obviously worth it

ccrawl could check -o off os.Args before the tree is built, which is what loadSettings already does for --profile, and fail with exit 2. That means hardcoding the format list in ccrawl. The list is the framework's, so the day any-cli adds a format, ccrawl rejects a value that works, and no test here would catch it. Trading a silent wrong answer for a wrong refusal is not clearly a win.

Filed so it is written down rather than rediscovered. Same disposition as the two framework flags whose help the renderer damages, recorded in the comment on TestFlagHelpSurvivesTheRenderer: ccrawl knows about it, the fix belongs in any-cli.

Activity

  1. added this to the v0.10.1 milestone on Aug 12, 2026
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

    area: cliCommand surface, flags, configpriority: P3Durability and polishtype: bugSomething is wrong

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions