Skip to content

Conversation

john-h-kastner-aws
Copy link
Contributor

Description of changes

In sandbox_b/policies_5_bad.cedar the validation error message was

× policy set validation failed
  ╰─▶ unable to guarantee safety of access to optional attribute `` for entity type User
    ╭─[14:10]
 13 │ when { resource.private }
 14 │ unless { resource.account.owner == principal };
    ·          ──────────────────────
    ╰────
  help: try testing for the attribute with `e has f && ..`

The attribute name was empty, it it thought the access happened on a User entity.
With this fix it correctly sees that the policy access owner on an Account entity.

  × policy set validation failed
  ╰─▶ unable to guarantee safety of access to optional attribute `owner` for entity type Account
    ╭─[14:10]
 13 │ when { resource.private }
 14 │ unless { resource.account.owner == principal };
    ·          ──────────────────────
    ╰────
  help: try testing for the attribute with `e has owner && ..`

Issue #, if available

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

  • A bug fix or other functionality change requiring a patch to cedar-policy.

I confirm that this PR (choose one, and delete the other options):

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).

I confirm that cedar-spec (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar formal model or DRT infrastructure.

@john-h-kastner-aws john-h-kastner-aws changed the title Fix validation error for invalid attribute on nested entity attribute Fix validation error msg for invalid attribute on nested entity attribute Apr 24, 2024
@shaobo-he-aws
Copy link
Contributor

Nit: is it possible to instantiate e in e has ...?

@john-h-kastner-aws
Copy link
Contributor Author

john-h-kastner-aws commented Apr 24, 2024

Nit: is it possible to instantiate e in e has ...?

With the new way we carry source range and original source code, I might be able to snip the exact original e out of the policy source if it's present. Otherwise using the Display for e would work well enough.

@john-h-kastner-aws john-h-kastner-aws merged commit d3b7826 into main Apr 24, 2024
@john-h-kastner-aws john-h-kastner-aws deleted the fix-attr-err branch April 26, 2024 13:12
john-h-kastner-aws added a commit that referenced this pull request May 6, 2024
john-h-kastner-aws added a commit that referenced this pull request May 7, 2024
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.

3 participants