Skip to content

fix(preflight): safely validate installer flags before shifting arguments - #6796

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/linux-preflight-option-args
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/linux-preflight-option-args

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/scripts/linux-install-preflight.sh, options requiring parameter values (--json-file, --ods-root, and --min-disk-gb) immediately performed shift 2 inside the argument parser without validating parameter presence or non-empty value boundaries. When invoked with a trailing flag without an argument under set -euo pipefail, the script aborted abruptly on shift 2 with unhandled status 1 and no diagnostic output; furthermore, if another flag was passed immediately following (e.g. --json-file --strict), the subsequent flag was silently consumed as the option's value rather than being evaluated.

This fix introduces surgical option argument guards matching the established CLI validation conventions in ODS scripts. If an argument is missing, empty, or starts with a hyphen indicating another flag, the script exits immediately with status 2 and writes a clear diagnostic message to stderr (Option <flag> requires an argument). Existing valid flag parsing, output defaults, and preflight evaluation routines remain completely untouched.

Validation

  • Baseline reproduction: Calling ods/scripts/linux-install-preflight.sh --json-file failed under set -euo pipefail on shift 2 with unhandled status 1 and empty stderr. Calling ods/scripts/linux-install-preflight.sh --json-file --strict silently consumed --strict as the JSON file path.
  • Post-fix validation: Missing or empty option arguments or flag hijacking immediately exit with exit code 2 and display Option <flag> requires an argument on stderr.
  • Telemetry: Preflight suites: 4 passed. New-test Ruff, 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 #6795 at 28743cc without conflicts. Production and test diffs passed together; capability and preflight 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 changed the title fix(preflight): reject missing option arguments in linux install preflight fix(preflight): safely validate installer flags before shifting arguments Sep 26, 2026
@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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