Skip to content

sdk: options store takes precedence over ext store #7800

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

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

srenatus
Copy link
Contributor

@srenatus srenatus commented Jul 25, 2025

Rationale is that if the user has passed a store into the SDK, it probably has something in it already, like data and policies.


Excellent rationale from @philipaconrad, copied here to make it stand out a bit more:

Thanks for putting this PR together! The changes here solve a potential "footgun" around using the SDK: if you registered a bundle store func elsewhere, you can wind up with 2x stores (one the user passed in, and one created by the store func for bundle storage)! 😨

That behavior is obviously surprising when you're using the SDK and populating the store yourself, so this change brings management of stores more into line with what users might expect: if they pass in a storage.Store instance, that's what gets used, and if they don't provide a choice, they get whatever default is available. (The bundle storage func gets invoked, or OPA makes them a new inmem store behind the scenes.)

Rationale is that if the user has passed a store into the SDK, it
probably has something in it already, like data and policies.

Signed-off-by: Stephan Renatus <[email protected]>
Copy link

netlify bot commented Jul 25, 2025

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 1b14353
🔍 Latest deploy log https://app.netlify.com/projects/openpolicyagent/deploys/6883d111bfa84800085eff66
😎 Deploy Preview https://deploy-preview-7800--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@philipaconrad philipaconrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this PR together! The changes here solve a potential "footgun" around using the SDK: if you registered a bundle store func elsewhere, you can wind up with 2x stores (one the user passed in, and one created by the store func for bundle storage)! 😨

That behavior is obviously surprising when you're using the SDK and populating the store yourself, so this change brings management of stores more into line with what users might expect: if they pass in a storage.Store instance, that's what gets used, and if they don't provide a choice, they get whatever default is available. (The bundle storage func gets invoked, or OPA makes them a new inmem store behind the scenes.)

@srenatus srenatus enabled auto-merge (rebase) July 25, 2025 18:55
@srenatus srenatus merged commit 9a73de9 into open-policy-agent:main Jul 25, 2025
31 checks passed
@srenatus srenatus deleted the sr/krkrsvlwoxsn branch July 25, 2025 18:57
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.

2 participants