Repository navigation
fix: Reject malformed dispatcher minimum versions consistently - #1590
Conversation
Route dispatcher pin and release automation version checks through the shared common/version parser so every caller rejects the same malformed semver inputs. Add coverage for leading-zero dispatcher minimums and refresh the dispatcher release input stamp after the common module change.
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a shared ChangesShared IsValid validation migration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@cubic-dev-ai review this PR after the latest commit. |
@qua-hatayama I have started the AI code review. It will take a few minutes to complete. |
Validate build metadata before accepting shared semver strings so dispatcher pins cannot pass path-like suffixes through IsValid.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cli/common/version/compare.go (1)
123-137: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCorrectly implements semver build-metadata validation.
Rejects empty/dot-separated-empty identifiers and restricts to alphanumeric+hyphen, matching semver 2.0's build-metadata rules (no leading-zero restriction applies here, unlike prerelease). This closes the path-smuggling gap the tests target (e.g.
3.0.0+../../payload).One minor observation:
isValidBuildMetadataduplicates most of the loop structure inisValidPrerelease(Lines 105-121), differing only by the leading-zero check. Consider extracting a shared identifier-list validator that takes an optional numeric-leading-zero check as a parameter to reduce duplication.🤖 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 `@cli/common/version/compare.go` around lines 123 - 137, `isValidBuildMetadata` currently duplicates the identifier-splitting logic from `isValidPrerelease`, making the two validators drift-prone. Refactor the shared loop into a common helper used by both `isValidBuildMetadata` and `isValidPrerelease`, and parameterize the leading-zero numeric check so prerelease keeps its restriction while build metadata skips it. Keep the existing character validation via `containsOnlyPrereleaseCharacters` and preserve the empty/dot-separated-empty rejection behavior.
🤖 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 `@cli/common/version/compare.go`:
- Around line 123-137: `isValidBuildMetadata` currently duplicates the
identifier-splitting logic from `isValidPrerelease`, making the two validators
drift-prone. Refactor the shared loop into a common helper used by both
`isValidBuildMetadata` and `isValidPrerelease`, and parameterize the
leading-zero numeric check so prerelease keeps its restriction while build
metadata skips it. Keep the existing character validation via
`containsOnlyPrereleaseCharacters` and preserve the empty/dot-separated-empty
rejection behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c4771a92-89d2-4954-b366-1da60208d074
📒 Files selected for processing (4)
cli/common/version/compare.gocli/common/version/compare_test.gocli/dispatcher/internal/dispatcher/dispatcher_test.gocli/dispatcher/shared-inputs-stamp.json
✅ Files skipped from review due to trivial changes (1)
- cli/dispatcher/shared-inputs-stamp.json
🚧 Files skipped from review as they are similar to previous changes (1)
- cli/common/version/compare_test.go
Use one helper for prerelease and build metadata identifier validation so the two semver paths stay aligned while preserving prerelease leading-zero rules.
Summary
User Impact
Changes
version.IsValidfor semver validation without self-comparison.Verification
go test ./versionfromcli/commongo test ./internal/dispatcher -run 'TestLoadDispatcherPinRejectsMinimumDispatcherVersionWithLeadingZero|TestLoadDispatcherPinRejectsInvalidMinimumDispatcherVersion|TestLoadDispatcherPinNormalizesVersionPrefixes'fromcli/dispatchergo test ./internal/automation -run 'TestParseProtocolMinimumVersionValues_WhenMinimumVersionIsInvalid_Fails'fromcli/release-automationscripts/check-go-cli.shgo run ./cmd/check-release-triggers --base origin/v3-beta --head HEADfromcli/release-automation