Skip to content

Conversation

@john-h-kastner-aws
Copy link
Contributor

Description of changes

Schema based parsing currently supports parsing action attributes according to their types, but the Cedar schema format does not support defining actions with their attributes or declaring the type of their attributes, so this code is not reachable by consumers of the Cedar library.

By deleting this code we can remove a caller of schematype_of_partialvalue which is known to be buggy for set and records.

Note that action entities are compared against the action entities from the schema when constructing an Entities object, so we still report an error if an action entity contains unexpected attributes.

Issue #, if available

Checklist for requesting a review

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

  • A breaking change requiring a major version bump to cedar-policy (e.g., changes to the signature of an existing API).
  • A backwards-compatible change requiring a minor version bump to cedar-policy (e.g., addition of a new API).
  • A bug fix or other functionality change requiring a patch to cedar-policy.
  • A change "invisible" to users (e.g., documentation, changes to "internal" crates like cedar-policy-core, cedar-validator, etc.)
  • A change (breaking or otherwise) that only impacts unreleased or experimental code.

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).
  • Does not update the CHANGELOG because my change does not significantly impact released code.

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.
  • Requires updates, and I have made / will make these updates myself. (Please include in your description a timeline or link to the relevant PR in cedar-spec, and how you have tested that your updates are correct.)
  • Requires updates, but I do not plan to make them in the near future. (Make sure that your changes are hidden behind a feature flag to mark them as experimental.)
  • I'm not sure how my change impacts cedar-spec. (Post your PR anyways, and we'll discuss in the comments.)

Action cannot be declared with attributes in the schema, so this code
path was not reachable from the public API. If we add action attributes
later, you now won't be able to use the schema-based parsing shortcuts
when parsing action entity data, but you can still fully re-use action
entities from the schema by not redefining them in the entity data.

Signed-off-by: John Kastner <[email protected]>
Signed-off-by: John Kastner <[email protected]>
@john-h-kastner-aws john-h-kastner-aws force-pushed the jkastner/rm_schema_parsing_action_attr branch from 1b1ad56 to 4b8c350 Compare September 11, 2024 14:56
Copy link
Contributor

@cdisselkoen cdisselkoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see some of this code being removed.

Comment on lines -346 to -350
EntitySchemaInfo::Action(action) => {
// We'll do schema-based parsing assuming optimistically that
// the type in the JSON is the same as the type in the schema.
// (As of this writing, the schema doesn't actually tell us
// what type each action attribute is supposed to be)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a behavior change -- suppose you have an action attribute of type ip in the schema, then with this code you're allowed to pass just "192.168.0.1" for that attribute in the entity data (ie, just a string), whereas after this code is removed, you'll need the { __extn: { ... } } form.

however, this is probably inconsequential, because most users are probably not passing actions in their entity data if they are also passing the schema, since the schema contains the action info and we already automatically pull the proper action info from the schema when constructing entities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a behavior change for actions with attributes, but the schema doesn't allow that currently.

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