Skip to content

Better error messages for Unexpected type errors #242

@shaobo-he-aws

Description

@shaobo-he-aws

Before opening, please confirm:

Bug Category

Schemas and Validation

Describe the bug

If we replace the Policy 2 of the TinyTodo example like this,

// Policy 2: A User can see a List if they are either a reader or editor
permit (
    principal,
    action == Action::"GetList",
    resource
)
when { 3 < resource.readers || principal in resource.editors };

We get error messages,

Unexpected type. Expected {"type":"Long"} but saw {"type":"Entity","name":"Team"}

Expected behavior

This error message could be more readable like Expected type 'Long' but saw entity type 'Team'

Reproduction steps

  1. Replace Policy 2
  2. Run cedar validate --schema tinytodo.cedarschema.json --policies policies.cedar

Code Snippet

// Put your code below this line.

Log output

// Put your output below this line

Additional configuration

No response

Operating System

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    papercutSmall annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions