-
Notifications
You must be signed in to change notification settings - Fork 93
fix(subs): fix cadence validations #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe billing cadence alignment validation logic for subscriptions was refactored. Validation was centralized into a new Changes
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
openmeter/subscription/workflow/service/subscription.go (2)
65-67
: Avoid double-wrappingGenericValidationError
ValidateAlignment()
already returns aGenericValidationError
(viamodels.NewNillableGenericValidationError
).
Wrapping it again creates a nested error of the same type and discards the original message details. A minimal pass-through preserves the original error while keeping the extra context:- if err := spec.ValidateAlignment(); err != nil { - return def, models.NewGenericValidationError(fmt.Errorf("billing cadences are not aligned: %w", err)) - } + if err := spec.ValidateAlignment(); err != nil { + // The returned err is already a *GenericValidationError – just enrich or pass it through. + return def, fmt.Errorf("billing cadences are not aligned: %w", err) + }(Repeat for the similar block below or extract a small helper to keep things DRY.)
152-154
: Same duplication – factor into helperThis block is identical to lines 65-67. Consider extracting a helper:
func wrapAlignmentErr(err error) error { if err == nil { return nil } return fmt.Errorf("billing cadences are not aligned: %w", err) }and call
return def, wrapAlignmentErr(spec.ValidateAlignment())
to keep both paths consistent and future-proof.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
openmeter/subscription/subscriptionspec.go
(1 hunks)openmeter/subscription/workflow/service/subscription.go
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
openmeter/subscription/workflow/service/subscription.go (1)
pkg/models/errors.go (1)
NewGenericValidationError
(138-140)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: Artifacts / Benthos Collector Container image
- GitHub Check: Artifacts / Container image
- GitHub Check: Commit hooks
- GitHub Check: E2E
- GitHub Check: Developer environment
- GitHub Check: CI
- GitHub Check: Migration Checks
- GitHub Check: Quickstart
- GitHub Check: Lint
- GitHub Check: Test
- GitHub Check: Build
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
openmeter/subscription/subscriptionspec.go (1)
349-349
: Cleaner nil-handling :+1Switching to
models.NewNillableGenericValidationError(errors.Join(errs...))
removes the explicitlen(errs)
branch while still returningnil
when appropriate. Good simplification.
Overview
Context: alignment is not a consistency guarantee but a runtime validation on change (this was a necessity we have data that cant be migrated to be consistent)
FIxes some incorrect validations
Notes for reviewer
Summary by CodeRabbit