Skip to content

Schema files should be able to refer to types in the empty namespace #579

@john-h-kastner-aws

Description

@john-h-kastner-aws

Category

Cedar validation features/changes

Describe the feature you'd like to request

In the following schema, there is an id common type without a namespace. We should be able to refer to it inside of a namespace, but the schema currently doesn't parse because we implicitly qualify id with the current namespace, and then look for Demo::id. When this type isn't found, schema parsing fails.

{
  "Demo": {
    "entityTypes": {
      "User": {
        "memberOfTypes": [],
        "shape": {
          "type": "Record",
          "attributes": {
            "id": { "type": "id" },
          }
        }
      }
    },
    "actions": {}
  },
  "": {
    "commonTypes": {
      "id": {
        "type": "String"
      },
    }
    "entityTypes": {},
    "actions": {}
  }
}

We should fix this in two ways:

  • When id doesn't exist in the current namespace, we should fall back to looking for it in the empty/global namespace. This schema would then parse as expected.
  • It should be possible to explicitly refer to types in the empty namespace. A possible syntax for this might be {"type": "::id"} (we should think about other possible syntax for this, and we also need a syntax for the human-readable schema format). This would allow referring to this definition of id even when another one is defined in this namespace.

The example in this issue uses commonTypes, but we should ensure that the behavior is consistent between commonTypes, entityTypes and actions which can all be qualified with a namespace.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working. This is as high priority issue.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions