Repository navigation
fix(cli): reject unknown --batch values in ocr scan - #2009
Open
Walternater wants to merge 1 commit into
Open
Walternater wants to merge 1 commit into
Walternater wants to merge 1 commit into
Conversation
validateScanOptions now validates the --batch strategy the same way it already validates --format: values outside none | by-language | by-directory fail fast with an error naming the flag. Previously a typo was silently discarded and the scan ran unbatched, because parseBatchStrategy falls back to BatchNone for unknown input. The lenient template-level BATCH_STRATEGY fallback is unchanged; only the CLI surface rejects typos early.
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2008
What
ocr scan --batchnow rejects values outside the documented set (none,by-language,by-directory) instead of silently discarding them:This matches the command's existing treatment of
--format(invalid --format value %q: must be 'text', 'json', or 'sarif').How
validateScanOptions(cmd/opencodereview/shared_flags.go) calls a newvalidateBatchStrategy, which trims and lower-cases the value (soBy-Directorystill works) and errors otherwise. Empty stays valid: it means "use the template default".opts.batchoverride in cmd/opencodereview/scan_cmd.go is updated accordingly.parseBatchStrategyin internal/scan/batch.go is unchanged: its lenient fallback is documented safe v1 behavior for the template-levelBATCH_STRATEGY, where arbitrary strings can also arrive from a user-suppliedscan_template.json. Only the CLI surface — where the flag help and shell completion advertise exactly three values — fails fast.Tests
TestParseScanFlags_InvalidBatch—bogus,by-languag,language,directoryall error, and the message names--batch.TestParseScanFlags_NormalizedBatch— the three valid values, mixed case/whitespace normalization, and empty passthrough.go test ./...passes;make checkpasses;make english-checkpasses.AI/LLM disclosure
This PR was prepared with AI assistance (DeepSeek Harness agent, model group/smart-split): code exploration, patch drafting, and test generation. Every changed line was reviewed and verified by running the built CLI locally on macOS (Apple Silicon) against commit a74bcbb.