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

JSON serialization changed for serde_json::value::RawValue #290

Closed
psFried opened this issue Sep 25, 2022 · 2 comments
Closed

JSON serialization changed for serde_json::value::RawValue #290

psFried opened this issue Sep 25, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@psFried
Copy link

psFried commented Sep 25, 2022

What happened?

We have some snapshot tests using some structs that include serde_json::value::RawValue fields. These tests started failing after upgrading from insta version 0.14.0 to 0.20.0. Here's an example of the diffs:

   43    43 │           "image": "ghcr.io/foo/bar/source-potato:v1.2.3",
   44       │-          "config": {"some":"config"}
         44 │+          "config": {
         45 │+            "$serde_json::private::RawValue": "{\"some\":\"config\"}"
         46 │+          }
   45    47 │         }
   46    48 │       },
   47    49 │       "bindings": [

Reproduction steps

  1. Use insta::assert_json_snapshot(MyStructWithRawValueField); with insta:1.14.0 and commit the snapshot.
  2. Upgrade insta dependency
  3. Observe failing test

Insta Version

1.14.0 -> 1.20.0

rustc Version

1.64

What did you expect?

I'm not entirely sure what the expected behavior should be here. The new representation actually seems reasonable from the standpoint that equality of a RawValue perhaps out to depend on the actual string representation rather than just the values of the parsed JSON. In other words, the new format causes semantically insignificant differences in the RawValue-wrapped JSON (such as whitespace) to be considered significant when comparing snapshots.

What do you think? Should this be considered a regression or a feature?

@psFried psFried added the bug Something isn't working label Sep 25, 2022
@mitsuhiko
Copy link
Owner

Ah interesting. Serde's in-band signalling strikes again (serde-rs/serde#1463). I did not expect this but now that it happened I would probably prefer to keep it this way.

I believe fundamentally serde needs to find a better way to represent these things and I probably don't want to hack this into this library now to match the behavior.

@psFried
Copy link
Author

psFried commented Sep 25, 2022

Makes sense. I'll consider it a 'happy accident' 😁 Thanks for the quick reply.

psFried added a commit to estuary/flow that referenced this issue Sep 25, 2022
Update insta, and updates a failing test due to breaking serialization
change. Issue for the serialization change: mitsuhiko/insta#290
psFried added a commit to estuary/flow that referenced this issue Sep 27, 2022
Update insta, and updates a failing test due to breaking serialization
change. Issue for the serialization change: mitsuhiko/insta#290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants