Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix camelCasing in FFI #831

Merged
merged 1 commit into from
May 2, 2024
Merged

fix camelCasing in FFI #831

merged 1 commit into from
May 2, 2024

Conversation

cdisselkoen
Copy link
Contributor

Description of changes

It turns out that if you put #[serde(rename_all = "camelCase")] on an enum, serde doesn't automatically recursively apply the attribute to fields inside enum variants, only to the enum variant names themselves.

#814 missed this, and as a result, did not camelCase the validation_errors and validation_warnings fields in ValidationAnswer. This PR finishes the job.

Our tests in this crate did not catch this because, although they use explicit JSON structures for call inputs (like ValidationCall), they do not use explicit JSON structures for call outputs (like ValidationAnswer), instead relying on serde to deserialize into ValidationAnswer and then check that. As a result, the tests are fine with any shape of ValidationAnswer as long as serde deserializes it correctly. This PR adds the minimal check that ValidationAnswer includes fields with the appropriate camelCase names when validation fails.

I discovered this when observing that cedar-policy/cedar-java#133 still needed to expect the snake_cased names for these fields. I think we should still merge that PR (which is compatible with #814) and then later as a followup make a new PR compatible with this one.

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).

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):

  • 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.)

Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
@cdisselkoen cdisselkoen added the breaking-change This is (likely) a breaking change label May 2, 2024
@cdisselkoen cdisselkoen requested a review from khieta May 2, 2024 15:52
@cdisselkoen cdisselkoen merged commit c43187d into main May 2, 2024
14 of 16 checks passed
@cdisselkoen cdisselkoen deleted the cdisselkoen/fix-camelCasing branch May 2, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This is (likely) a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants