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

Rego type error comparing generated object with partial hard coded object #6751

Open
asleire opened this issue May 16, 2024 · 0 comments
Open
Labels

Comments

@asleire
Copy link
Contributor

asleire commented May 16, 2024

Short description

Play: https://play.openpolicyagent.org/p/1qlgPwcNXA

Snippet:

obj["a"] := input.a

obj["b"] := input.b

test_obj2 if {
	{"a":"1"} == obj with input as {"a": "1"}
}

The code should be valid but gives the following compile error:

1 error occurred: policy.rego:32: rego_type_error: match error
	left  : object<a: string>
	right : object<a: any, b: any>[string: any]

Steps To Reproduce

View play and click "Evaluate"

Expected behavior

I would expect this comparison to be valid since b may be undefined and not part of the object. Evaluating obj with input as {"a": "1"} reveals that it is in fact {"a":"1"}. As such there should be no compile error.

@asleire asleire added the bug label May 16, 2024
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