chore: switch JSON to encoding/json/v2 - #138
Open
acoshift wants to merge 1 commit into
Open
Conversation
Migrate marshal/unmarshal call sites to encoding/json/v2. Retag bool/number/pointer/time fields from omitempty to omitzero so v2's redefined omitempty does not drop location feature flags, send 0 for "use server default" ints, or emit year-1 timestamps. Site manifests pass json.Deterministic so release-sha map key order stays stable. --- Requested via Grok Work Prompter: ACS Prompter: ACS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate the shared API types and HTTP client from
encoding/jsontoencoding/json/v2(Go 1.27).Why the tag changes
v2 redefines
omitemptyto mean “omit if this would encode as empty JSON” (null,"",[],{}), not “omit if the Go value is zero”. A naive import swap would have broken the public wire:disk/waf/cache/transformas non-nil*struct{}) encode as{}. v2omitemptywould drop them, so the console’sloc.features.diskgates would treat every location as unsupported. Those fields (and other bool/number/pointer/time fields whose zero value means “absent”) now useomitzero, which is the v1-equivalent “omit Go zero” and is supported by both packages.minSize/ttl(0 = server default) would have been sent as0instead of omitted.time.Time(certPendingSince, DNSverifiedAt) never omitted under v1omitempty(structs are not “empty”).omitzeroactually omits them, which matches the console’s optional-string types and avoids year-1 timestamps.String/slice/map
omitemptyis unchanged between v1 and v2 and is left as-is.Other v2 semantics (intentional)
[]/{}rather thannull. The console already usesitems ?? [].json.Deterministic(true)so the files object’s key order stays stable forsha256(v2 maps are otherwise non-deterministic).Request decode on the apiserver is still arpc’s v1 decoder (separate PR). This PR only changes the
apimodule.Tests
{"disk":{},...}when enabled and{}when absent.[]; email address string/object forms.Requested via Grok Work
Prompter: ACS