fix(cli): reject a malformed coordinator address/port in dora up - #3100
fix(cli): reject a malformed coordinator address/port in dora up#3100phil-opp wants to merge 2 commits into
dora up#3100Conversation
`dora up` read DORA_COORDINATOR_ADDR / DORA_COORDINATOR_PORT with `.and_then(|s| s.parse().ok()).unwrap_or(default)`, so a present but unparseable value (e.g. a typo'd port) was silently discarded and the default was used. Every other lifecycle command reads the same env vars through clap's typed `env=` on `CoordinatorOptions`, which errors on an unparseable value. The result was a silent divergence: `DORA_COORDINATOR_PORT=abc dora up` started a coordinator on the default port while `dora stop`/`list`/`down` aborted with an invalid-value error and could not find it. Add a small `coordinator_env_value` helper that returns the default only when the var is unset and errors when it is set but unparseable, and route both reads through it. Adds unit tests for the unset/valid/malformed cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1Fmp8pELuTiPGTStomkZj
|
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 |
Follow-up to the /simplify review: the two call sites each repeated the
env var name once as the error-label argument and once inside
`std::env::var("…")`, which could drift out of sync. Fold the
`std::env::var(...)` read into `coordinator_env_value` so callers name
each variable once, and keep the raw-value seam as a private
`parse_coordinator_env` that the unit tests target without touching the
process environment.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1Fmp8pELuTiPGTStomkZj
|
🤖 Automated review by Claude Code — fully automated review, not vetted by a human. No issues found. The change replaces the silent One minor behavioral note, not a blocker: an env var set to an empty string (e.g. Generated by Claude Code |
Issue
dora upresolved the coordinator location fromDORA_COORDINATOR_ADDR/DORA_COORDINATOR_PORTlike this (binaries/cli/src/command/up.rs):.and_then(|s| s.parse().ok())throws away a parse error, so a present-but-unparseable value silently falls back to the default. Every other lifecycle command reads the same two env vars through clap's typedenv=onCoordinatorOptions(common.rs), which errors on an unparseable value.The result is a silent divergence:
DORA_COORDINATOR_PORT=abc dora upstarts a coordinator on the default port53290, whiledora stop/dora list/dora downabort withinvalid value for '--coordinator-port'— so they can no longer find the coordinator thatupjust started.Fix
Add a small
coordinator_env_valuehelper that returns the default only when the variable is unset, and returns an error when it is set but unparseable — mirroring the strictness ofCoordinatorOptions. Route both reads through it. Behavior is unchanged for the unset case and for valid values.Validation
coordinator_env_tests): unset → default, valid → parsed, malformed → error (not defaulted).cargo +1.97.1 fmt -p dora-cli -- --check— clean.cargo +1.97.1 clippy -p dora-cli -- -D warnings— clean.cargo +1.97.1 test -p dora-cli coordinator_env— 3 passed.🤖 Generated with Claude Code
Generated by Claude Code