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

Unexpected undefined result and evaluation error #505

Closed
tsandall opened this issue Nov 16, 2017 · 0 comments
Closed

Unexpected undefined result and evaluation error #505

tsandall opened this issue Nov 16, 2017 · 0 comments
Labels

Comments

@tsandall
Copy link
Member

Minimal example policy:

package ex

a = "a"
b = "b"

x = "x"
y = "y"

o[a] = {
    x: "foo"
}

o[b] = {
    y: "bar"
}

Queries:

# OK
> data.ex.o
{
  "a": {
    "x": "foo"
  },
  "b": {
    "y": "bar"
  }
}

#OK
> data.ex.o.a
{
  "x": "foo"
}

#Should be "foo"
> data.ex.o.a.x
undefined

#OK
> data.ex.o[i]
+-----+--------------+
|  i  | data.ex.o[i] |
+-----+--------------+
| "a" | {"x":"foo"}  |
| "b" | {"y":"bar"}  |
+-----+--------------+

#Unexpected error
> data.ex.o[i][j]
value requires evaluation (ast.Var)
@tsandall tsandall added the bug label Nov 16, 2017
tsandall added a commit to tsandall/opa that referenced this issue Nov 16, 2017
If object keys (or set elements) are vars, then they must be plugged
before lookup is attempted, otherwise lookup will fail and expression
will be undefined. This could result in poor performance if rule outputs
are large enough. In that case, we could revisit how the rule outputs
are constructed (e.g., we could construct outputs with the first level
of set/object plugged and propagate binding lists for each key/value
pair.)

Also, updated test runner to accept OPA_TRACE_TEST environment var to
selectively enable tracing output. This is useful for debugging
purposes.

Fixes open-policy-agent#505
tsandall added a commit that referenced this issue Nov 16, 2017
If object keys (or set elements) are vars, then they must be plugged
before lookup is attempted, otherwise lookup will fail and expression
will be undefined. This could result in poor performance if rule outputs
are large enough. In that case, we could revisit how the rule outputs
are constructed (e.g., we could construct outputs with the first level
of set/object plugged and propagate binding lists for each key/value
pair.)

Also, updated test runner to accept OPA_TRACE_TEST environment var to
selectively enable tracing output. This is useful for debugging
purposes.

Fixes #505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant