Skip to content
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

Improve handling of base document dereference with composite value #1057

Closed
tsandall opened this issue Nov 7, 2018 · 0 comments · Fixed by #1787
Closed

Improve handling of base document dereference with composite value #1057

tsandall opened this issue Nov 7, 2018 · 0 comments · Fixed by #1787
Assignees

Comments

@tsandall
Copy link
Member

tsandall commented Nov 7, 2018

If you try to refer to a base document with a composite key value, the storage function will return an error that halts evaluation. For example, if data is empty then data.foo.bar will return undefined, but data.foo[["bar"]] will return an error.

OPA should not return an error in this case, the result should just be undefined.

We can fix this issue by updating the evaluator to check the ref contains any non-scalar values before reading from storage. If a non-scalar value is found, we can return undefined immediately.

patrick-east added a commit to patrick-east/opa that referenced this issue Sep 26, 2019
Previously this would raise an error when attempting to build the
storage path for some ref like `data.foo[["bar"]]`, but there isn't
really any reason why it should halt evaluation. It should just
be undefined.

This changes to look for this type of ref _before_ handing it off to
the store and will just return undefined now instead.

Fixes: open-policy-agent#1057
Signed-off-by: Patrick East <east.patrick@gmail.com>
patrick-east added a commit that referenced this issue Sep 26, 2019
Previously this would raise an error when attempting to build the
storage path for some ref like `data.foo[["bar"]]`, but there isn't
really any reason why it should halt evaluation. It should just
be undefined.

This changes to look for this type of ref _before_ handing it off to
the store and will just return undefined now instead.

Fixes: #1057
Signed-off-by: Patrick East <east.patrick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants