fix(cli): reject a malformed DORA_COORDINATOR_ADDR/PORT in dora up - #3205
fix(cli): reject a malformed DORA_COORDINATOR_ADDR/PORT in dora up#3205phil-opp wants to merge 1 commit into
dora up#3205Conversation
`dora up` is the only place in the CLI that parses the coordinator address
and port env vars by hand:
let addr = std::env::var("DORA_COORDINATOR_ADDR")
.ok().and_then(|s| s.parse().ok()).unwrap_or(LOCALHOST);
The `.and_then(|s| s.parse().ok())` swallows a parse error, so a malformed
value (e.g. `DORA_COORDINATOR_PORT=70000` out of u16 range, `6O12` with a
letter O, or a non-IP `DORA_COORDINATOR_ADDR`) silently falls back to the
default endpoint. Every other subcommand routes the same env vars through
clap's typed `value_parser` (see `common.rs`, `daemon.rs`, `build/mod.rs`,
`coordinator.rs`), which hard-errors on a bad value — so the next
`dora start`/`list`/`stop` in the workflow rejects the value `up` just
ignored, or connects to the default port and reports the coordinator as not
running. The two halves of the same workflow disagree about where the
coordinator lives, with no diagnostic.
Parse both vars strictly via small helpers that surface a contextual error,
falling back to the default only when the var is unset — matching the clap
behavior of the other subcommands. Adds unit tests for the absent, valid,
and malformed cases.
This change is machine-generated by Claude (Claude Code). It has been
reviewed locally (fmt + clippy + dora-cli tests) but should be
human-reviewed before merge.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DY5kNaoUXqmLD3VYGLrSv4
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Automated review by Claude (fully automated; no human in the loop) No issues found. The change correctly replaces the error-swallowing Generated by Claude Code |
|
Automated review by Claude (fully automated; no human in the loop) This change looks to have been overtaken by #3100 ("fix(cli): reject a malformed coordinator address/port in The semantics of the two approaches match: unset → default, malformed → hard error naming the offending variable, empty string → error (consistent with clap's Given #3100 already landed the same behavior, this PR looks redundant. I'd suggest closing it, unless the two-typed-helper form here is preferred over the merged generic helper — in which case it needs a rebase that reconciles the duplicate Generated by Claude Code |
Summary
dora upis the only place in the CLI that parses the coordinator address and port env vars by hand:The
.and_then(|s| s.parse().ok())swallows a parse error, so a malformed value silently falls back to the default endpoint:DORA_COORDINATOR_PORT=70000(out ofu16range) → binds the default portDORA_COORDINATOR_PORT=6O12(letterOtypo) → binds the default portDORA_COORDINATOR_ADDR=<not-an-ip>→ binds loopbackEvery other subcommand routes the same env vars through clap's typed
value_parser(seecommon.rs,daemon.rs,build/mod.rs,coordinator.rs), which hard-errors on a bad value. So the nextdora start/dora list/dora stopin the same workflow rejects the valueupjust ignored — or connects to the default port and reports the coordinator as "not running". The two halves of a single workflow disagree about where the coordinator lives, with no diagnostic.Fix
Parse both vars strictly via two small helpers that surface a contextual error (
invalid DORA_COORDINATOR_ADDR…``), falling back to the default only when the var is unset — matching clap's behavior in the sibling subcommands. The helpers take anOption<String>(rather than reading the env internally) so the parse logic is unit-testable without mutating process env.Note: a var set to an empty string now hard-errors, which is intentional — clap's
env=in the other subcommands rejects an empty value too, so this keepsupconsistent with them (treating empty as "unset" would reintroduce the very divergence this fixes).Validation
cargo fmt -p dora-cli -- --check,cargo clippy -p dora-cli -- -D warnings(the CI gate command), andcargo test -p dora-cli coordinator_env_testspass locally on rustc 1.97.1. Onlyup.rsis touched.🤖 Generated with Claude Code
Generated by Claude Code