Skip to content

Refuse unknown options in mob.deploy instead of ignoring them - #63

Merged
GenericJam merged 1 commit into
masterfrom
fix/deploy-reject-unknown-flags
Sep 5, 2026
Merged

Refuse unknown options in mob.deploy instead of ignoring them#63
GenericJam merged 1 commit into
masterfrom
fix/deploy-reject-unknown-flags

Conversation

@GenericJam

Copy link
Copy Markdown
Owner

mix mob.deploy -d <udid> deployed to every connected device rather than the one named, and said nothing. Two silent causes: -d was never aliased to --device in this task (mob.connect has aliased it all along), and OptionParser.parse was called with switches:, which drops anything unrecognised and carries on. A typo'd --devcie behaved the same way.

Found while verifying MOB-151: two native builds went to the physical iPhone instead of the simulator I had named, and I spent a while assuming the device auto-detection was at fault.

Same class as MOB-150 — a run doing something other than what was asked and reporting success — so it gets the same treatment: strict: parsing, the alias added for parity with mob.connect, and a Mix.raise naming the offending options rather than a generic usage dump.

Device-verified: --ios -d <sim-udid> now pushes to one device where it previously pushed to all; --devcie foo exits 1 with Unknown option(s): --devcie.

2256 tests, credo and format clean.

`mix mob.deploy -d <udid>` deployed to every connected device rather than the
one named, and said nothing. Two causes, both silent: `-d` was never aliased to
`--device` in this task, though `mob.connect` has aliased it all along; and
`OptionParser.parse` was called with `switches:`, which drops anything it does
not recognise and carries on. A typo'd `--devcie` behaved the same way.
Found while verifying MOB-151, where two native builds went to the physical
iPhone instead of the simulator I had named, and I spent a while assuming the
device auto-detection was at fault.
This is the MOB-150 class exactly — a run doing something other than what was
asked and reporting success — so it gets the same treatment: `strict:` parsing,
the alias added for parity with `mob.connect`, and a `Mix.raise` that names the
options rather than a generic usage dump.
Device-verified: `--ios -d <sim-udid>` now pushes to one device where it
previously pushed to all, and `--devcie foo` exits 1 with
"Unknown option(s): --devcie".
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@GenericJam
GenericJam merged commit e8e4cb0 into masterSep 5, 2026
3 checks passed
GenericJam added a commit that referenced this pull request Sep 5, 2026
…ger works (#67)
A post-hoc review of #63 — which I merged without one — found that switching
`mix mob.deploy` to strict parsing broke the documented invocation.
`OptionParser` will not consume a dash-prefixed argument as a `:string` value,
so `--beam-flags "-S 4:4 -A 4"` parses as two unknown options. BEAM flags
essentially all begin with a dash, so this is not an edge case: it is every
spelling this repo prints, in seven places — the task's own moduledoc, five
README recipes, and the "untuned variant" step of both battery benchmarks.
Under the old lenient parsing the value was silently dropped and the deploy
carried on with whatever `mob.exs` held, which is its own bug. Strict parsing
turned that into a hard abort whose message named `--beam-flags` — a valid
option — as unknown. So the fix for one silent failure produced a loud wrong
one, and shipped because I skipped the review on a change I had filed mentally
as small.
`--flag value` is now rewritten to `--flag=value` when the value starts with a
dash, for string-valued switches only. Doing it for every switch would swallow
the flag after a boolean.
Three more from the same review:
The error conflated "unrecognised flag" with "recognised flag, unparseable
value" and discarded the value, so `--schedulers abc` reported `--schedulers`
as unknown and sent the reader to a help page that lists it.
`mob.new_plugin` already handled this correctly; this now matches.
Positional arguments were still silently dropped. `mix mob.deploy --native
ABC123` — a natural fumble of `--device` — parsed cleanly and deployed to
every device, which is the identical symptom to the bug #63 set out to fix,
in the same task, left in place by it.
The four tests #63 shipped were all source-text assertions and none ran the
parser, so none could have caught any of this. There is now a table test over
every invocation the docs actually print, which fails if a switch is renamed
or a documented spelling stops working.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for freeto 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.

1 participant

@GenericJam