-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Index out of range error in handling of bound refs #238
Labels
Comments
tsandall
added a commit
to tsandall/opa
that referenced
this issue
Feb 3, 2017
References were not being evaluated correctly. The top-level evalRefRec function was computing the ground prefix from the reference's binding and then performing the rest of the evaluation with the original reference and the prefix. Instead, the rest of the evaluation should proceed with the plugged value and the prefix. This fix was not compatible with how reference bindings were stored. Before, reference bindings were keyed with the original (potentially non-ground) reference. Now, they are keyed with the evaluated version of the reference. This version is guaranteed to be ground. As a result, the PlugValue handling of references must be updated to handle cases such as: orig ref: p[x][y] locals: {x: 1, y: 2} refs: {p[1][2]: "foo"} The solution is to recursively plug the ref. E.g., p[x][y] => p[1][y] => p[1][2] => "foo". Fixes open-policy-agent#238
tsandall
added a commit
to tsandall/opa
that referenced
this issue
Mar 22, 2017
If the entire ref is already bound, do not bother re-evaluating it. This prevents a recursive binding from being added in the case where the same local ref appears twice and is bound to a data ref. The fix for open-policy-agent#238 was caused a stack overflow in this case! Fixes open-policy-agent#298
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Evaluation encounters an index out of range error if the ref being evaluated is bound to another ref that has a longer ground prefix than the original ref. For instance:
When the second ref to "p" is evaluated, the ground prefix is obtained from the binding for p (which is is data.a.b.c.d).
Example:
The text was updated successfully, but these errors were encountered: