Skip to content

Conversation

cdisselkoen
Copy link
Contributor

Description of changes

using the already existing JsonValueWithNoDuplicateKeys created for Core

Issue #, if available

Checklist for requesting a review

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

  • A change "invisible" to users (e.g., documentation, changes to "internal" crates like cedar-policy-core, cedar-validator, etc.)

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

  • 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 Dafny model or DRT infrastructure.

Disclaimer

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

/// `__entity` and `__extn` escapes to be implicit, and it will error if
/// attributes have the wrong types (e.g., string instead of integer).
#[serde(rename = "schema")]
schema: Option<serde_json::Value>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Schema parsing should already be forbidding duplicate keys everywhere, so this should just move the error message around a bit. I don't see anything wrong with that, and consistently using the no-duplicates variant is nice, but maybe think about if the new error is substantially better/worse than before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's the case. serde_json::Value cannot contain duplicate keys, so any schema parsing that accepts serde_json::Value won't ever see the duplicate keys -- they would already be silently dropped (last-value-wins) during whatever process created the serde_json::Value.

@cdisselkoen cdisselkoen merged commit 9b70ba5 into main Nov 17, 2023
@cdisselkoen cdisselkoen deleted the tweak/cdisselkoen/duplicate-keys branch November 17, 2023 16:22
@sarahcec sarahcec added the 3.0 label Nov 27, 2023
shaobo-he-aws added a commit that referenced this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants