Repository navigation
[codex] Exclude locked namespaces from invoice collection - #4630
Conversation
📝 WalkthroughWalkthroughAdds an ChangesExcluded Namespaces Filtering
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Nice tidy little change here — one new field ripples cleanly from input struct to query filter to caller, keeping locked namespaces out of the invoice party! 🐰✨ 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Greptile SummaryThis PR skips locked namespaces during collectable invoice discovery. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "feat(billing): exclude locked namespaces..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openmeter/billing/worker/collect/collect.go (1)
145-167: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant locked-namespace filter now that the query already excludes them.
Since
ListCollectableInvoicesnow passesExcludedNamespaces: a.lockedNamespacesdown to the adapter query, the returnedinvoicesshould already have locked namespaces filtered out. The subsequentcustomerIDsfilter at Line 165-167 re-checking!slices.Contains(a.lockedNamespaces, id.Namespace)is now dead weight — worth trimming for clarity.♻️ Suggested cleanup
- customerIDs := lo.Map(invoices, func(i billing.GatheringInvoice, _ int) customer.CustomerID { - return customer.CustomerID{ - Namespace: i.Namespace, - ID: i.CustomerID, - } - }) - - customerIDs = lo.Filter(lo.Uniq(customerIDs), func(id customer.CustomerID, _ int) bool { - return !slices.Contains(a.lockedNamespaces, id.Namespace) - }) + customerIDs := lo.Uniq(lo.Map(invoices, func(i billing.GatheringInvoice, _ int) customer.CustomerID { + return customer.CustomerID{ + Namespace: i.Namespace, + ID: i.CustomerID, + } + }))If there's a reason to keep the defense-in-depth check (e.g., distrust of the adapter layer), a short comment explaining that intent would help future readers.
🤖 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 `@openmeter/billing/worker/collect/collect.go` around lines 145 - 167, Remove the redundant locked-namespace check from the customer ID post-processing in collect.go: ListCollectableInvoices already excludes a.lockedNamespaces, so the extra lo.Filter over customerIDs that re-applies !slices.Contains(a.lockedNamespaces, id.Namespace) is unnecessary. Update the collect flow around ListCollectableInvoices and customerIDs to keep only the unique mapping, or add a brief comment near that filter if you intentionally want defense-in-depth.
🤖 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 `@openmeter/billing/worker/collect/collect.go`:
- Around line 145-167: Remove the redundant locked-namespace check from the
customer ID post-processing in collect.go: ListCollectableInvoices already
excludes a.lockedNamespaces, so the extra lo.Filter over customerIDs that
re-applies !slices.Contains(a.lockedNamespaces, id.Namespace) is unnecessary.
Update the collect flow around ListCollectableInvoices and customerIDs to keep
only the unique mapping, or add a brief comment near that filter if you
intentionally want defense-in-depth.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: be31d6c1-6d2e-4bd0-ab1e-62eea908f076
📒 Files selected for processing (3)
openmeter/billing/adapter/gatheringinvoice.goopenmeter/billing/gatheringinvoice.goopenmeter/billing/worker/collect/collect.go
Summary
Impact
Locked namespaces are skipped by collection discovery without blocking explicit namespace/customer filtering for the remaining collection path.
Validation
Summary by CodeRabbit