Skip to content

fix: strengthen plan namespace isolation - #4906

Closed
turip wants to merge 6 commits into
mainfrom
feat/strengthen-plan-namespace-isolation
Closed

turip wants to merge 6 commits into
mainfrom
feat/strengthen-plan-namespace-isolation

Conversation

@turip

@turip turip commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Overview

This PR makes namespace handling consistent across product-catalog plan reads, writes, phase persistence, currency resolution, and plan add-on assignments.

High-level changes

  • changes plan listing to accept one required namespace throughout the handler, service, and repository layers
  • scopes plan graph loading, including phases and rate cards, to the requested namespace
  • resolves custom currencies, features, and tax codes through namespace-scoped lookups before persisting plan changes
  • carries the plan's namespaced identity into phase creation and validates that phase ownership remains consistent
  • resolves both parent resources before creating a plan add-on assignment
  • adds focused repository and resolver coverage for plan creation, updates, reads, and assignments

Review guide

The main implementation is split between the plan repository changes in openmeter/productcatalog/plan/adapter, shared custom-currency resolution, and plan add-on persistence. The adapter tests exercise the behavior at the repository boundary.

Stack

This PR is stacked on #4905 and should be reviewed after the parent PR.

Testing

  • POSTGRES_HOST=127.0.0.1 go test -count=1 -tags=dynamic ./openmeter/productcatalog/currencyresolver ./openmeter/productcatalog/plan/... ./openmeter/productcatalog/planaddon/...

No Jira ticket; this is a bug fix.

Greptile Summary

The PR consistently carries a required namespace through plan listing, graph loading, reference validation, phase persistence, currency resolution, and plan add-on assignment.

  • Replaces multi-namespace plan-list inputs with one required namespace.
  • Adds namespace predicates to plan graph and expanded-reference queries.
  • Validates currencies, features, tax codes, phases, and assignment parents against resource ownership.
  • Adds repository-level tests for cross-namespace reads and writes.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
openmeter/productcatalog/plan/adapter/plan.go Requires one namespace for listing and applies it consistently to plan graph loading and mutation validation.
openmeter/productcatalog/plan/adapter/references.go Validates referenced currencies, features, and tax codes against the plan namespace before persistence.
openmeter/productcatalog/plan/adapter/phase.go Carries the parent plan's namespaced identity into phase creation and rejects ownership mismatches.
openmeter/productcatalog/currencyresolver/resolver.go Rejects pre-resolved custom currencies owned by a namespace other than the active resolver namespace.
openmeter/productcatalog/planaddon/adapter/planaddon.go Resolves both assignment parents within the requested namespace before creating the relationship.
api/v3/handlers/plans/list.go Passes the resolved request namespace through the new singular list input.
openmeter/productcatalog/plan/adapter/adapter_test.go Adds focused persistence tests for namespace-scoped plan graphs, references, phases, and add-on assignments.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Request[Namespaced plan request] --> Service[Plan service]
  Service --> Currency[Namespaced currency resolution]
  Service --> Repository[Plan repository]
  Repository --> References[Validate features, tax codes, and currencies]
  Repository --> Plan[(Plan)]
  Plan --> Phase[(Namespaced phases)]
  Phase --> RateCard[(Namespaced rate cards)]
  Plan --> Assignment[Plan add-on assignment]
  Assignment --> Addon[(Namespaced add-on)]
Loading

Reviews (2): Last reviewed commit: "fix: strengthen plan namespace isolation" | Re-trigger Greptile

Context used:

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0850f619-50c0-4932-96d2-073388e74862

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@turip
turip force-pushed the feat/strengthen-plan-namespace-isolation branch from 98f42f6 to 44000a8 Compare August 11, 2026 09:06
Base automatically changed from feat/strengthen-namespace-isolation to main August 11, 2026 09:56
@turip turip closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant