Clarifying intended usage of object.get for defensive policies #737
Replies: 2 comments 11 replies
-
|
Hey, thanks for opening the discussion here. it would be nice to get an example of the path functionality in object.get documented on this page: https://www.openpolicyagent.org/docs/policy-reference/builtins/object Generally we like examples to be based on 'real' rego tasks, do you have an example from your domain that might make sense to others? |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the clarification. A real use-case I’ve encountered while learning Rego is defensive access to user attributes derived from auth/JWT input, where fields may be optional. For example:
This allows policies to safely handle missing user, profile, or role fields while keeping the intent explicit. If this sounds useful, I can draft a small PlaygroundExample for the object builtins page based on this pattern. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi folks,
While learning Rego, I spent some time experimenting with
object.getand wanted to sanity-check my understanding before proposing any documentation changes.From hands-on testing, it seems
object.getis primarily intended for:I personally understood this only after trial & error and running small local examples.
Reading the current docs, it wasn’t immediately obvious to me:
object.getover direct access (input.foo.bar),Before opening any PR, I wanted to ask:
object.get?Happy to follow whatever guidance makes most sense here.
Thanks!
cc @charlieegan3
Beta Was this translation helpful? Give feedback.
All reactions