Skip to content

fix: handle missing namespace filter - #4615

Merged
turip merged 1 commit into
mainfrom
feat/fix-missing-namespace-filter
Jun 30, 2026
Merged

turip merged 1 commit into
mainfrom
feat/fix-missing-namespace-filter

Conversation

@turip

@turip turip commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix gathering invoice listing so an omitted namespace filter means "do not filter by namespace" instead of producing an empty NamespaceIn() predicate.

Details

ListGatheringInvoices already treats customer, currency, and ID filters as optional. This change makes namespace filtering follow the same contract by applying NamespaceIn(...) only when namespaces are provided.

The regression test creates a gathering invoice and lists it by customer without passing Namespaces, proving callers can use non-namespace filters without accidentally excluding all rows.

Validation

  • make lint
  • make test-nocache

Summary by CodeRabbit

  • Bug Fixes
    • Listing gathering invoices now works correctly when no namespace filter is provided, returning matching invoices instead of excluding them.
    • Added coverage to confirm invoices can still be found by customer alone and return the expected namespace and customer details.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 45c1741c-d7d0-4cad-9548-e9ba600ec9cb

📥 Commits

Reviewing files that changed from the base of the PR and between 79c88f3 and 34d79b8.

📒 Files selected for processing (2)
  • openmeter/billing/adapter/gatheringinvoice.go
  • test/billing/invoice_test.go

📝 Walkthrough

Walkthrough

ListGatheringInvoices in the billing adapter now conditionally applies the NamespaceIn query filter only when input.Namespaces is non-empty. A new test validates that calling the function with only a Customers filter (no namespaces) returns the correct invoice.

Changes

Empty Namespace Filter Guard

Layer / File(s) Summary
Guard NamespaceIn + test coverage
openmeter/billing/adapter/gatheringinvoice.go, test/billing/invoice_test.go
NamespaceIn(...) is now only added to the query when input.Namespaces is non-empty. A new test provisions an invoice and asserts ListGatheringInvoices returns it correctly when called with no namespace filter.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • chrisgacsal
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: treating a missing namespace filter as optional in ListGatheringInvoices.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fix-missing-namespace-filter

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes gathering invoice namespace filtering optional when listing invoices.

  • Applies NamespaceIn only when namespaces are provided.
  • Keeps the gathering status filter as the base query condition.
  • Adds a billing test for listing by customer without a namespace filter.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
openmeter/billing/adapter/gatheringinvoice.go Changes gathering invoice listing so an empty namespace slice means no namespace predicate instead of an empty NamespaceIn filter.
test/billing/invoice_test.go Adds regression coverage for listing a gathering invoice by customer while omitting Namespaces.

Reviews (1): Last reviewed commit: "fix: handle missing namespace filter" | Re-trigger Greptile

@turip turip added release-note/bug-fix Release note: Bug Fixes area/billing labels Jun 30, 2026
@turip
turip marked this pull request as ready for review June 30, 2026 13:41
@turip
turip requested a review from a team as a code owner June 30, 2026 13:41
@turip
turip merged commit 6c5367e into main Jun 30, 2026
28 of 31 checks passed
@turip
turip deleted the feat/fix-missing-namespace-filter branch June 30, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants