fix(hermes): guard pruner flags against missing parameters and unhandled shifts - #6794
Open
vaibhavsrv wants to merge 1 commit into
Open
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
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.
Why this matters
In
ods/scripts/prune-hermes-slash-workers.sh, option flags requiring values (--max-count,--max-age-seconds,--container) read$2and executeshift 2underset -euo pipefailwithout checking if an argument was provided. Passing any of these options as the trailing argument crashes the script with an unhandled exit code 1 and completely empty standard error, giving operators no diagnostic feedback. Furthermore, passing an option without a value immediately before another flag (e.g.,--container --forceor--max-count --dry-run) causes the parser to swallow the subsequent flag into the option parameter; in the--container --forcecase, this runs Docker commands against an invalid container name, suppresses--force, prints an unrecognized option warning from grep, and emits a false-positive[PASS] no Hermes slash workers foundwith exit code 0.This change introduces pre-shift parameter presence and option-flag validation across
--max-count,--max-age-seconds, and--container. If an argument is missing, empty, or starts with a hyphen indicating another option flag, the script outputs a clear diagnostic ([FAIL] <option> requires an argument), displays usage information, and exits cleanly with usage status 1. Valid arguments, dry-run mode, and worker process filtering contracts remain untouched.Validation
bash ods/scripts/prune-hermes-slash-workers.sh --containeron unpatched code terminated with unhandled status 1 and empty stderr; passingbash ods/scripts/prune-hermes-slash-workers.sh --container --forcesilently swallowed--forceintoCONTAINERand produced a false-positive exit 0.python3 ods/tests/test_prune_hermes_slash_workers_options.pyconfirms that missing trailing options, empty argument values, and option flag hijacking are rejected with exit code 1 and informative diagnostics, while valid arguments dispatch cleanly.Overlap check
install-core.sh,ods-backup.sh,pre-download.sh, andods-test.sh; did not touchprune-hermes-slash-workers.sh.prune-hermes-slash-workers.sh; touches an entirely distinct downstream filter and does not overlap with option parsing.validate-compose-stack.sh; separate validation script.Risk / AI disclosure
AI-assisted investigation, implementation and CLI regressions. This strengthens a CLI check, not runtime admission. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.
Follow-up integration evidence
Composed with #6770 at 6c455ba without conflicts. Production and test diffs passed together; update dry-run checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.