-
Notifications
You must be signed in to change notification settings - Fork 113
fix: make sure that split lines are expanded for line service #3054
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughA validation was added to ensure that any line belonging to a split line group must also have a corresponding split line hierarchy. In addition, logic in the methods determining if a line is the first or last in a period was adjusted to remove early returns based on missing split line hierarchy data. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 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. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
✨ Finishing Touches
🧪 Generate unit tests
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: 0
🧹 Nitpick comments (1)
openmeter/billing/service/lineservice/linebase.go (1)
109-114
: Fix the error message typo and approve the validation logic.The validation logic correctly enforces that split line groups must have their hierarchy expanded, which aligns with the PR objective. However, there's a grammatical error in the error message.
Apply this diff to fix the error message:
- return billing.ValidationError{ - Err: fmt.Errorf("split line group[%s] has no hierarchy expanded hierarchy", *l.line.SplitLineGroupID), - } + return billing.ValidationError{ + Err: fmt.Errorf("split line group[%s] has no expanded hierarchy", *l.line.SplitLineGroupID), + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openmeter/billing/service/lineservice/linebase.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: Quickstart
- GitHub Check: Developer environment
- GitHub Check: Commit hooks
- GitHub Check: CI
- GitHub Check: Migration Checks
- GitHub Check: Lint
- GitHub Check: E2E
- GitHub Check: Test
- GitHub Check: Build
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
openmeter/billing/service/lineservice/linebase.go (1)
119-141
: EnsurelineBase.Validate
Guards Before Period MethodsThe
Validate(ctx, invoice)
method onlineBase
correctly errors whenSplitLineGroupID != nil
butSplitLineHierarchy
is nil, soIsLastInPeriod
/IsFirstInPeriod
will only see a non-nil hierarchy if validation has run. You need to confirm the service always invokesValidate
on eachlineBase
before calling these methods.• Inspect
openmeter/billing/service/lineservice/service.go
to verify there’s alineBase.Validate(ctx, invoice)
call for every code path that usesIsLastInPeriod()
orIsFirstInPeriod()
.
• If any usage of these methods isn’t protected byValidate
, either:
– Add nil checks at the top of each method:
go if l.line.SplitLineHierarchy == nil { // fall back or safe default return true }
– Or ensureValidate
is invoked unconditionally before those calls.
f9fa528
to
f440848
Compare
Overview
This changes #2990 so that we are not missreporting the start/end of the period in case the hierarchy is not expanded, instead we are making sure that we are returning an error.
Summary by CodeRabbit