You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
### Description
Fixes#6232
This PR allows us to properly deserialize semver versions from YAML in
`yarn.lock`. Previously we would fail at parsing ranges with trailing
zeros e.g. `(0.10f32).to_string() == "0.1"`.
The approach taken in this PR is due to some outstanding quirks in
`serde_yaml`:
-
dtolnay/serde-yaml#165 (comment)
- dtolnay/serde-yaml#388
Our usage of `#[serde(flatten)]` in `LockfileData` caused attempting to
parse `2` or `0.10` as a `String` to fail. To avoid this we first parse
the document as a map with a union of the metadata/package entries and
then convert this to the expected structure. This provides us the type
safety of the old implementation, but at the cost of rebuilding the map.
As a minor thing, I removed all unused `Serialize`/`Deserialize`
implementations to make it clear which codepaths actually get used.
### Testing Instructions
Existing unit tests pass.
I changed out the old unit tests for `SemverString` to be captured by
the new `berry_semver.lock` test fixture which covers the same cases. We
do this because even if parsing versions works when invoked directly,
adding `#[serde(flatten)]`/`#[serde(untagged)]` to any containing
structure changes the behavior.
Closes TURBO-1540
---------
Co-authored-by: Chris Olszewski <Chris Olszewski>
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In the following example the first struct deserializes , but the second one fails with "invalid type: integer
42
, expected a string".The text was updated successfully, but these errors were encountered: