fix(api-model): avoid panic parsing build versions with a "-dirty" suffix#3775
fix(api-model): avoid panic parsing build versions with a "-dirty" suffix#3775kurotych wants to merge 1 commit into
Conversation
Signed-off-by: Anatolii Kurotych <akurotych@gmail.com>
Walkthrough
ChangesBuild Version Dirty-State Support
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/api-model/src/machine/upgrade_policy.rs (1)
320-459: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExpand dirty-version regression coverage.
The new test covers only the five-part parser branch and checks
is_dirty; it does not verifyDisplayround-tripping or dirty inputs handled by the other parser branches. Add table-driven cases for representative shapes and abuild_version_display_round_tripscase ending in-dirty.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/api-model/src/machine/upgrade_policy.rs` around lines 320 - 459, Expand the version parser test table with dirty-input cases covering the other supported shapes, not only the five-part branch, and assert the expected is_dirty and parsed fields. Add a build_version_display_round_trips test using a BuildVersion whose formatted output ends with “-dirty”, verifying parsing the displayed value reproduces the original version.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/api-model/src/machine/upgrade_policy.rs`:
- Around line 320-459: Expand the version parser test table with dirty-input
cases covering the other supported shapes, not only the five-part branch, and
assert the expected is_dirty and parsed fields. Add a
build_version_display_round_trips test using a BuildVersion whose formatted
output ends with “-dirty”, verifying parsing the displayed value reproduces the
original version.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ef3b2e3f-a421-4272-aa12-210b0f17d78e
📒 Files selected for processing (1)
crates/api-model/src/machine/upgrade_policy.rs
|
/ok to test 98c94c0 |
|
@kfelternv, could you please take a look at this follow-up? PR #2560 introduced the root images-core target with:
That makes locally built images report versions ending in -dirty, which exposed this parser failure. |
Bug description
The NICo API panicked at runtime
The root cause is a combination of:
--dirtykey:VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)BuildVersionparser which can't parse the default-generated version string like:v2.0.0-rc.2-9-g0401aad9f-dirtyProposed solution
Strip the
-dirtysuffix before parsing BuildVersion if present.Related issues
Type of Change
Breaking Changes
Testing