Skip to content

fix(compose): reject missing option arguments in validate-compose-stack.sh - #6452

Closed
vaibhavsrv wants to merge 3 commits into
Osmantic:mainfrom
vaibhavsrv:fix/validate-compose-option-args-v2
Closed

vaibhavsrv wants to merge 3 commits into
Osmantic:mainfrom
vaibhavsrv:fix/validate-compose-option-args-v2

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/scripts/validate-compose-stack.sh, the CLI argument parsing loop unconditionally executed shift 2 when encountering --compose-flags or --env-file. When either option was passed as the final argument without a corresponding parameter value, executing shift 2 under set -euo pipefail caused Bash to halt abruptly with an unhandled exit 1 and an empty standard error. Consequently, the script's intended check (ERROR: --compose-flags required) was never reached. Furthermore, passing an option without a value immediately before another supported flag (such as --compose-flags --quiet or --env-file --compose-flags) caused the parser to mistakenly swallow the subsequent flag as the argument value, suppressing the flag's effect and forwarding invalid configuration to Docker Compose.

This change introduces pre-shift parameter presence validation for both --compose-flags and --env-file. If an argument is missing, empty, or set to another option flag, the parser outputs an informative diagnostic (ERROR: <option> requires an argument) to standard error and exits cleanly with usage status 1. Valid arguments, combined flags, and downstream Docker Compose invocation contracts remain intact.

Validation

  • Baseline reproduction: Running bash ods/scripts/validate-compose-stack.sh --compose-flags or --env-file halted with unhandled exit code 1 and an empty standard error; passing --compose-flags --quiet silently swallowed --quiet into COMPOSE_FLAGS and attempted an invalid compose config.
  • Post-fix verification: Running ods/tests/test_validate_compose_stack_option_args.py confirms that missing, empty, or option-hijacking invocations fail with exit code 1 and output the appropriate ERROR: <option> requires an argument diagnostic, while valid invocations dispatch cleanly.
  • Telemetry statement: Compose validation suites: 6 passed, caller suites (test_support_bundle_timeouts): 10 passed. New-test PyCompile, ShellCheck, and diff checks pass; new regressions wired into Linux CI.

Overlap check

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 #6447 at ce21032 without conflicts. Production and test diffs passed together; compose validation and diagnostic bundle 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.

@vaibhavsrv vaibhavsrv closed this Sep 23, 2026
@vaibhavsrv
vaibhavsrv deleted the fix/validate-compose-option-args-v2 branch September 23, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants