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/eval: conflict errors in functions when output not captured #3920

Conversation

srenatus
Copy link
Contributor

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.

Signed-off-by: Stephan Renatus stephan.renatus@gmail.com

@srenatus srenatus marked this pull request as ready for review October 25, 2021 10:17
tsandall
tsandall previously approved these changes Oct 26, 2021
Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will likely affect a small portion of users who have policies that rely on functions that are currently generating conflicting values. It would be good to include a release note with an example that people can grok with a suggestion of how to fix it.

@srenatus srenatus force-pushed the sr/issue-3912/func-output-not-captured branch from e2ce183 to f51eb64 Compare October 27, 2021 08:19
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 srenatus force-pushed the sr/issue-3912/func-output-not-captured branch from f51eb64 to 94a9d6e Compare October 27, 2021 08:28
Copy link
Member

@peteroneilljr peteroneilljr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@srenatus srenatus merged commit dc2019d into open-policy-agent:main Oct 27, 2021
@srenatus srenatus deleted the sr/issue-3912/func-output-not-captured branch October 27, 2021 08:46
dolevf pushed a commit to dolevf/opa that referenced this pull request 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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