Skip to content

fix(launcher): refuse a flag or empty value after a value-taking option - #44

Merged
github-actions[bot] merged 3 commits into
mainfrom
fix/launcher-option-values
Oct 21, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
fix/launcher-option-values

Conversation

@znerol2

@znerol2 znerol2 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The launcher's value-taking options (--image, --port, --repo-base-url) accepted the next argument as their value even when it was another flag, because ${2:?...} rejects only a missing or empty value. dmf-init up --repo-base-url --tls took --tls as the URL, and --image --port 8080 failed with "unknown option '8080'" instead of blaming --image.

A small need_value helper now refuses an empty value or one that starts with --, naming the option. Nothing else in the parser changed. This is an install-path bug, inside the v0.1 scope for the installer.

Verification

  • test/launcher/test-dmf-init.sh gained an "option values" block that sources the launcher, stubs cmd_up and calls main, so it needs no container runtime. Before the fix: 51 passed, 10 failed (a following flag reached cmd_up for each option; --image --port 8080 blamed the wrong option). After: 61 passed, 0 failed. Removing the --* case from the helper fails the harness again.
  • shellcheck bin/dmf-init: clean before and after. bin/dmf-init --help unchanged.

Closes dmfdeploy/dmfdeploy#160

--image, --port and --repo-base-url took "${2:?...}", which rejects only a
missing value. "dmf-init up --repo-base-url --tls" silently stored "--tls"
as the base URL and left TLS off.

Add need_value, which rejects an empty value or one starting with "--" and
names the option. The three options call it before assigning.

The launcher test sources the script, stubs cmd_up and checks that each
option rejects a following flag and an empty value, and that valid values
still parse. The flag cases fail on the old parser.

Refs dmfdeploy/dmfdeploy#160

Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
@znerol2
znerol2 requested a review from a team as a code owner October 21, 2026 07:00
@znerol2
znerol2 requested a review from lkirc October 21, 2026 07:00
@github-actions
github-actions Bot enabled auto-merge (rebase) October 21, 2026 07:00
… terminal

The launcher opens the synthesised URL with open or xdg-open when either
is on PATH. The harness shimmed docker and curl but not the openers, so a
run that reached that step started the real browser.

Add no-op open and xdg-open stubs that record their argument next to the
fake docker and curl. Two new checks confirm the open step called the stub
with the synthesised URL and that both openers resolve to the shim. With
the stubs removed and a logging open on PATH, the checks fail and the
logging open receives the fixture URLs.

Refs dmfdeploy/dmfdeploy#160

Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>

@lkirc lkirc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin/dmf-init:391 only rejects values beginning with --. The documented short flag -h is still accepted as the value of --image/--port/--repo-base-url (for example, dmf-init up --image -h reaches cmd_up) instead of reporting that the prior option needs a value. Reject any option-looking value (and add a -h regression case).

need_value only rejected values that began with --, so the documented
short flag -h was accepted as the value of --image, --port and
--repo-base-url. 'dmf-init up --image -h' reached cmd_up instead of
reporting that --image needs a value.

need_value now rejects any value that starts with a dash. The launcher
test gains -h cases next to the -- cases: nonzero exit, the option is
named, and cmd_up is not reached. Before the fix the new cases failed
(passed=64 failed=9); after it the suite passes (passed=73 failed=0).
The harness stubs open and xdg-open.

Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
@znerol2
znerol2 requested a review from lkirc October 21, 2026 11:26

@lkirc lkirc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review complete: the prior short-flag concern is resolved; the value guard and focused regression coverage look correct. Required checks are green.

@github-actions
github-actions Bot merged commit 9c77cae into main Oct 21, 2026
10 checks passed
@znerol2
znerol2 deleted the fix/launcher-option-values branch October 21, 2026 12:25
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.

dmf-init launcher: value-taking options swallow a following flag as their value

2 participants