refactor(updater): replace manual parsing with struct definitions#4162
refactor(updater): replace manual parsing with struct definitions#4162lucasfernog merged 4 commits intodevfrom
Conversation
|
@JonasKruckenberg I know you'll think the deserialize impl is too ugly, but it's needed to have better error messages. |
Hmmm, you're right, that is very ugly... 😂 Can't we use something like https://github.com/dtolnay/path-to-error and simply convert the serde_json errors into something nicer, without weird whacky struct workarounds? |
We can't, serde doesn't give us any information with the flatten attribute, so the path_to_error crate just returns |
|
Stupid flatten 🙄 another idea, we just duplicate |
|
We also need to duplicate the ReleaseManifestPlatform fields right? url, signature and with_elevated_task since that's where the flatten is used. |
|
Hmmm the Dynamic variant would either have to duplicate or use use But would flatten in that context still be a problem? |
|
I think flatten is always a problem for the error message. |
tweidinger
left a comment
There was a problem hiding this comment.
Looks good to me. I don't see breaking or security impact changes. The PR mentions additionally (breaking) changes which sound like good improvements. Especially the chrono type for the date.
|
@JonasKruckenberg I tried the enum change, but this is what serde_json gives me: |
It very much looks like it yeah :/ |
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___)Other information
There a number of chances to further tighten down the interface, but they would introduce a breaking change (something @nothingismagick explicitly wanted to avoid)
target. Currentlytargetis a String. By creating a custom typeUpdateTarget { os, arch }we could constrain the target to valid target combinations only and outright reject unsupported/malformed targets. This would also help to solve [bug]UpdateBuilder::targetweird behavior when specifying target #4161.versionfield to be strict semver. Currently we accept bothv1.0.0and1.0.0but only the latter is valid semver (thesemvercrate will reject the former). Requiring strict semver would allow us to get rid of the custom deserialize fn. This would also have the advantage that theshould_updatecallback would receive properVersionstructs instead of&strand could perform comparisons much easier (and reliably).versionorname. We never havenamein any docs and it's rather obscure. Getting rid of it would simplify the interface.pub_date. Currentlypub_dateis a String, and we pass it through as-is. chrono::DateTime is ISO 8601 and implementsDeserialize. This would make updates more secure as malformed dates would be rejected during deseralization as soon as possible.