-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
refactor(updater): replace manual parsing with struct definitions #4162
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
. Currentlytarget
is 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::target
weird behavior when specifying target #4161.version
field to be strict semver. Currently we accept bothv1.0.0
and1.0.0
but only the latter is valid semver (thesemver
crate 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_update
callback would receive properVersion
structs instead of&str
and could perform comparisons much easier (and reliably).version
orname
. We never havename
in any docs and it's rather obscure. Getting rid of it would simplify the interface.pub_date
. Currentlypub_date
is 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.