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

topdown: functions with multiple outputs for one input don't trigger error when output isn't captured #3912

Closed
srenatus opened this issue Oct 22, 2021 · 1 comment · Fixed by #3920
Labels

Comments

@srenatus
Copy link
Contributor

package test

r(x) {
  data.test.q(x)
}

p(x) {
   y := data.test.q(x)
}

q(_) = true
q(_) = false
query return
data.test.r(1) true
data.test.p(1) eval_conflict_error: functions must not produce multiple outputs for same inputs
data.test.q(1) eval_conflict_error: functions must not produce multiple outputs for same inputs

data.test.r(1) should return the same error, I suppose. The comparison with prev is missing here, I think: https://github.com/open-policy-agent/opa/blob/v0.33.1/topdown/eval.go#L1697-L1701

@srenatus srenatus added the bug label Oct 22, 2021
srenatus added a commit to srenatus/opa that referenced this issue Oct 25, 2021
With func1.rego as

    package test
    r(x) {
      data.test.q(x)
    }
    q(_) = true
    q(_) = false

Before:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    true

After:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    1 error occurred: func1.rego:12: eval_conflict_error: functions must not produce multiple outputs for same inputs

Fixes open-policy-agent#3912.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
@srenatus
Copy link
Contributor Author

Checked what -t wasm does, it gives us a straight row of func1.rego:12:1: var assignment conflict ✔️

srenatus added a commit to srenatus/opa that referenced this issue Oct 27, 2021
With func1.rego as

    package test
    r(x) {
      data.test.q(x)
    }
    q(_) = true
    q(_) = false

Before:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    true

After:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    1 error occurred: func1.rego:12: eval_conflict_error: functions must not produce multiple outputs for same inputs

Fixes open-policy-agent#3912.

Also adds a CHANGELOG item making the backwards-compat-breaking change
prominent, and sharing an example of how to fix it.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
srenatus added a commit that referenced this issue Oct 27, 2021
…3920)

With func1.rego as

    package test
    r(x) {
      data.test.q(x)
    }
    q(_) = true
    q(_) = false

Before:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    true

After:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    1 error occurred: func1.rego:12: eval_conflict_error: functions must not produce multiple outputs for same inputs

Fixes #3912.

Also adds a CHANGELOG item making the backwards-compat-breaking change
prominent, and sharing an example of how to fix it.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
dolevf pushed a commit to dolevf/opa that referenced this issue Nov 4, 2021
…pen-policy-agent#3920)

With func1.rego as

    package test
    r(x) {
      data.test.q(x)
    }
    q(_) = true
    q(_) = false

Before:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    true

After:

    $ opa eval -fpretty -d func1.rego 'data.test.r(1)'
    1 error occurred: func1.rego:12: eval_conflict_error: functions must not produce multiple outputs for same inputs

Fixes open-policy-agent#3912.

Also adds a CHANGELOG item making the backwards-compat-breaking change
prominent, and sharing an example of how to fix it.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Dolev Farhi <farhi.dolev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant