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

partial evaluation return unknown value #5471

Open
jaredzhou opened this issue Dec 10, 2022 · 3 comments
Open

partial evaluation return unknown value #5471

jaredzhou opened this issue Dec 10, 2022 · 3 comments

Comments

@jaredzhou
Copy link

Version: opa linux client 0.47
res.rego

package res

allow {                                    
    has_role                         
}

has_role {
# user_role := data.project.user_roles[_]
  user_role := data[input.res.type].user_roles[_]
  user_role.user_name == input.user.name
}

input.json

{
    "user": {
        "name": "jared"
    },
    "action": "read",
    "res": {
        "type": "project"
    }
}

command

opa eval  -d ./res.rego   -i input.json -u data.project.user_roles -p "data.res.allow"

and it report an error

{
  "errors": [
    {
      "message": "unknown value"
    }
  ]
}

when i change user_role := data[input.res.type].user_roles[_] to user_role := data.project.user_roles[_] which is the same since input.res.type is project. i don't know if it's a bug, but it's a feature i want, so i can choose res_type from input

@jaredzhou jaredzhou added the bug label Dec 10, 2022
@srenatus
Copy link
Contributor

Thanks for the report. Someone will have to dig in a bit more, this isn't obvious. I think what you're suggesting is alright. (💭 Perhaps it's even related to #5470?)

@stale
Copy link

stale bot commented Jan 12, 2023

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Jan 12, 2023
@stale stale bot removed the inactive label Mar 8, 2023
@stale
Copy link

stale bot commented Apr 7, 2023

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants