[go] encoding/json/v2: document custom marshal option adherence

7 views
Skip to first unread message

Michael Pratt (Gerrit)

unread,
Aug 4, 2026, 1:59:05 PM (8 days ago) Aug 4
to Michael Pratt, goph...@pubsubhelper.golang.org, Joseph Tsai, Damien Neil, Jonathan Amsterdam, golang-co...@googlegroups.com
Attention needed from Damien Neil and Joseph Tsai

Michael Pratt voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • Joseph Tsai
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
Gerrit-Change-Number: 810320
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Jonathan Amsterdam <j...@google.com>
Gerrit-Attention: Damien Neil <dn...@google.com>
Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
Gerrit-Comment-Date: Tue, 04 Aug 2026 17:59:02 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Jonathan Amsterdam (Gerrit)

unread,
Aug 5, 2026, 11:39:37 AM (7 days ago) Aug 5
to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
Attention needed from Damien Neil, Joseph Tsai and Michael Pratt

Jonathan Amsterdam added 5 comments

File src/encoding/json/v2/options.go
Line 117, Patchset 1 (Latest):// Unless StringifyNumbers was applied globally, the option does not
Jonathan Amsterdam . unresolved

I'm confused by what it means to apply an option globally. I thought it meant at the top level of a marshal call, but the last sentence here contradicts that. So how do I set this option so that it applies recursively to numbers in arrays and objects?

Line 140, Patchset 1 (Latest):// Determinism is guaranteed across different instances of the exact same
Jonathan Amsterdam . unresolved

nit: remove

or replace "exact same" with "identical"

Line 145, Patchset 1 (Latest):// serialize in a deterministic manner if it is true.
Jonathan Amsterdam . unresolved

deterministically (?)

Line 145, Patchset 1 (Latest):// serialize in a deterministic manner if it is true.
Jonathan Amsterdam . unresolved

a custom

Line 145, Patchset 1 (Latest):// serialize in a deterministic manner if it is true.
Jonathan Amsterdam . unresolved

Maybe something like this:
There is only one nondeterministic operation typically encountered while traversing go data structures: iterating over a map produces the entries in random order. Sorting the keys is the usual fix, and that is in fact what the implementation does.

Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • Joseph Tsai
  • Michael Pratt
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
    Gerrit-Change-Number: 810320
    Gerrit-PatchSet: 1
    Gerrit-Owner: Michael Pratt <mpr...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Comment-Date: Wed, 05 Aug 2026 15:39:31 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Jonathan Amsterdam (Gerrit)

    unread,
    Aug 5, 2026, 11:40:54 AM (7 days ago) Aug 5
    to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil, Joseph Tsai and Michael Pratt

    Jonathan Amsterdam added 1 comment

    File src/encoding/json/v2/options.go
    Line 145, Patchset 1 (Latest):// serialize in a deterministic manner if it is true.
    Jonathan Amsterdam . unresolved

    Maybe something like this:
    There is only one nondeterministic operation typically encountered while traversing go data structures: iterating over a map produces the entries in random order. Sorting the keys is the usual fix, and that is in fact what the implementation does.

    Jonathan Amsterdam

    or if you don't like "fix", then maybe "approach to making this deterministic"

    Gerrit-Comment-Date: Wed, 05 Aug 2026 15:40:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Jonathan Amsterdam <j...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Michael Pratt (Gerrit)

    unread,
    Aug 5, 2026, 1:22:48 PM (7 days ago) Aug 5
    to Michael Pratt, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Damien Neil, Joseph Tsai and Michael Pratt

    Michael Pratt uploaded new patchset

    Michael Pratt uploaded patch set #2 to this change.
    Following approvals got outdated and were removed:
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Joseph Tsai
    • Michael Pratt
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 2
      unsatisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      Aug 5, 2026, 1:53:25 PM (7 days ago) Aug 5
      to Michael Pratt, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Joseph Tsai and Michael Pratt

      Michael Pratt uploaded new patchset

      Michael Pratt uploaded patch set #3 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Joseph Tsai
      • Michael Pratt
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 3
      unsatisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      Aug 5, 2026, 1:53:51 PM (7 days ago) Aug 5
      to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, Damien Neil, Jonathan Amsterdam, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Jonathan Amsterdam and Joseph Tsai

      Michael Pratt voted and added 5 comments

      Votes added by Michael Pratt

      Commit-Queue+1

      5 comments

      File src/encoding/json/v2/options.go
      Line 117, Patchset 1:// Unless StringifyNumbers was applied globally, the option does not
      Jonathan Amsterdam . unresolved

      I'm confused by what it means to apply an option globally. I thought it meant at the top level of a marshal call, but the last sentence here contradicts that. So how do I set this option so that it applies recursively to numbers in arrays and objects?

      Michael Pratt

      This option is a bit special (I hate this option).

      The primary way to use this option is to set the "string" field tag. That is a "non-global" use: a field `f Foo "json:,string"` will see `StringifyNumbers` set in its MarshalJSONTo. But if that MarshalJSONTo calls MarshalEncode to marshal some sub-field then the option will be cleared.

      A "global" use is simply passing `json.StringifyNumbers(true)` to a json.Marshal call, or any other `Marshal*` call.

      This "global" term isn't well defined. I've rewritten this to just talk about the "string" tag vs explicit uses of the option. PTAL

      Line 140, Patchset 1:// Determinism is guaranteed across different instances of the exact same
      Jonathan Amsterdam . resolved

      nit: remove

      or replace "exact same" with "identical"

      Michael Pratt

      Done

      Line 145, Patchset 1:// serialize in a deterministic manner if it is true.
      Jonathan Amsterdam . resolved

      Maybe something like this:
      There is only one nondeterministic operation typically encountered while traversing go data structures: iterating over a map produces the entries in random order. Sorting the keys is the usual fix, and that is in fact what the implementation does.

      Jonathan Amsterdam

      or if you don't like "fix", then maybe "approach to making this deterministic"

      Michael Pratt

      My new patch set on CL 809760 adds "For example, Go maps are marshaled sorted by key."

      Line 145, Patchset 1:// serialize in a deterministic manner if it is true.
      Jonathan Amsterdam . resolved

      a custom

      Michael Pratt

      MarshalFunc/MarshalToFunc can override marshaling of built in types, so it doesn't technically need to be a custom type.

      Line 145, Patchset 1:// serialize in a deterministic manner if it is true.
      Jonathan Amsterdam . resolved

      deterministically (?)

      Michael Pratt

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Jonathan Amsterdam
      • Joseph Tsai
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 3
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-CC: Jonathan Amsterdam <j...@google.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
      Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Comment-Date: Wed, 05 Aug 2026 17:53:45 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Jonathan Amsterdam <j...@google.com>
      unsatisfied_requirement
      open
      diffy

      Jonathan Amsterdam (Gerrit)

      unread,
      Aug 5, 2026, 2:51:53 PM (7 days ago) Aug 5
      to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Joseph Tsai and Michael Pratt

      Jonathan Amsterdam voted and added 1 comment

      Votes added by Jonathan Amsterdam

      Code-Review+2

      1 comment

      File src/encoding/json/v2/options.go
      Line 117, Patchset 1:// Unless StringifyNumbers was applied globally, the option does not
      Jonathan Amsterdam . resolved

      I'm confused by what it means to apply an option globally. I thought it meant at the top level of a marshal call, but the last sentence here contradicts that. So how do I set this option so that it applies recursively to numbers in arrays and objects?

      Michael Pratt

      This option is a bit special (I hate this option).

      The primary way to use this option is to set the "string" field tag. That is a "non-global" use: a field `f Foo "json:,string"` will see `StringifyNumbers` set in its MarshalJSONTo. But if that MarshalJSONTo calls MarshalEncode to marshal some sub-field then the option will be cleared.

      A "global" use is simply passing `json.StringifyNumbers(true)` to a json.Marshal call, or any other `Marshal*` call.

      This "global" term isn't well defined. I've rewritten this to just talk about the "string" tag vs explicit uses of the option. PTAL

      Jonathan Amsterdam

      Acknowledged

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Joseph Tsai
      • Michael Pratt
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 3
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
      Gerrit-Attention: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Comment-Date: Wed, 05 Aug 2026 18:51:47 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
      Comment-In-Reply-To: Jonathan Amsterdam <j...@google.com>
      satisfied_requirement
      open
      diffy

      Joseph Tsai (Gerrit)

      unread,
      Aug 6, 2026, 6:40:41 AM (6 days ago) Aug 6
      to Michael Pratt, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, golang...@luci-project-accounts.iam.gserviceaccount.com, Damien Neil, golang-co...@googlegroups.com
      Attention needed from Damien Neil and Michael Pratt

      Joseph Tsai added 5 comments

      File src/encoding/json/v2/arshal_methods.go
      Line 79, Patchset 3 (Latest):// [jsontext.(*Encoder).Options] and adjust behavior to respect the options as
      Joseph Tsai . resolved

      Does [jsontext.Encoder.Options] not work?

      IIUC, you can't declare a non-pointer method if the pointer method already exists right? so there should be no ambiguity.

      Line 85, Patchset 3 (Latest):// - [StringifyNumbers]
      Joseph Tsai . unresolved

      Perhaps comment on how doing so is only necessary if the representation itself is a JSON number? For most other cases where you're implementing a high-order composite type, then recursively calling `json.MarshalEncode` will handle this for you.

      Line 87, Patchset 3 (Latest):// The following options typically only apply to native Go types. These will be
      Joseph Tsai . unresolved

      I feel like everything past this point is too much detail. I find references v1 legacy options in the v2 API unfortunate.

      Line 160, Patchset 3 (Latest):// - [StringifyNumbers]
      Joseph Tsai . unresolved

      Perhaps comment on how doing so is only necessary if the representation itself is a JSON number? For most other cases where you're implementing a high-order composite type, then recursively calling json.MarshalEncode will handle this for you.

      Line 162, Patchset 3 (Latest):// The following options typically only apply to native Go types. These will be
      Joseph Tsai . unresolved

      I feel like everything past this point is too much detail. I find references v1 legacy options in the v2 API unfortunate.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Michael Pratt
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 3
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Comment-Date: Thu, 06 Aug 2026 10:40:32 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      Aug 6, 2026, 1:15:25 PM (6 days ago) Aug 6
      to Michael Pratt, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Jonathan Amsterdam and Michael Pratt

      Michael Pratt uploaded new patchset

      Michael Pratt uploaded patch set #4 to this change.
      Following approvals got outdated and were removed:
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Jonathan Amsterdam
      • Michael Pratt
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 4
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
      unsatisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      Aug 6, 2026, 1:16:16 PM (6 days ago) Aug 6
      to Michael Pratt, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Jonathan Amsterdam and Joseph Tsai

      Michael Pratt added 6 comments

      File src/encoding/json/v2/arshal_funcs.go
      Line 167, Patchset 4 (Latest):// Implementations must not return [errors.ErrUnsupported].
      Michael Pratt . unresolved

      Are Marshaler implementations allowed to return errors.ErrUnsupported? They don't say one way or another.

      File src/encoding/json/v2/arshal_methods.go
      Line 79, Patchset 3:// [jsontext.(*Encoder).Options] and adjust behavior to respect the options as
      Joseph Tsai . resolved

      Does [jsontext.Encoder.Options] not work?

      IIUC, you can't declare a non-pointer method if the pointer method already exists right? so there should be no ambiguity.

      Michael Pratt

      Done.

      Line 85, Patchset 3:// - [StringifyNumbers]
      Joseph Tsai . resolved

      Perhaps comment on how doing so is only necessary if the representation itself is a JSON number? For most other cases where you're implementing a high-order composite type, then recursively calling `json.MarshalEncode` will handle this for you.

      Michael Pratt

      Done, though I'm not convinced what I've captured in one sentence is better than encouraging users to read the full docs.

      Line 87, Patchset 3:// The following options typically only apply to native Go types. These will be
      Joseph Tsai . unresolved

      I feel like everything past this point is too much detail. I find references v1 legacy options in the v2 API unfortunate.

      Michael Pratt

      I had two reasons for breaking out this first section:

      1. To tell users to use MarshalEncode to marshal other types inside a composite (rather than e.g., attempting to manually encode a slice), so these options are respected.

      2. If a custom type semantically represents a slice, they may want to check FormatNilSliceAsNull and format as "null" or "[]" for maximum compatibility with v1.

      In retrospect, I'm not sure (2) is wise. Today, the type's MarshalJSON presumably returns "null". Users may migrate to v2 before you get a chance to add MarshalJSONTo, so they would still "null" in v2. When you do add MarshalJSONTo, they would see a change to "[]" without adjusting any options. That implies that custom types should use an alternative option for this kind of migration.

      This could make more sense for a new custom type after 1.27, so there is no compatibility issue. But for a brand new type, there is also less reason why they would actually want "null".

      (Or if you are implementing a MarshalToFunc for an actual slice type.)

      I find references v1 legacy options in the v2 API unfortunate.

      While I agree it is unfortunate, implementations of MarshalJSONTo need to be compatible with v1 users. If we need to reference v1 so they have the information they need to write a compatible implementation, so be it.

      I've removed this list in favor of listing a single example option, but I still think an exhaustive list would be more helpful.

      The final section is fine to drop.

      Line 160, Patchset 3:// - [StringifyNumbers]
      Joseph Tsai . resolved

      Perhaps comment on how doing so is only necessary if the representation itself is a JSON number? For most other cases where you're implementing a high-order composite type, then recursively calling json.MarshalEncode will handle this for you.

      Michael Pratt

      Done

      Line 162, Patchset 3:// The following options typically only apply to native Go types. These will be
      Joseph Tsai . resolved

      I feel like everything past this point is too much detail. I find references v1 legacy options in the v2 API unfortunate.

      Michael Pratt

      Acknowledged

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Jonathan Amsterdam
      • Joseph Tsai
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 4
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
      Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Comment-Date: Thu, 06 Aug 2026 17:16:10 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Joseph Tsai <joe...@digital-static.net>
      unsatisfied_requirement
      open
      diffy

      Damien Neil (Gerrit)

      unread,
      Aug 10, 2026, 6:43:24 PM (2 days ago) Aug 10
      to Michael Pratt, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, golang-co...@googlegroups.com
      Attention needed from Joseph Tsai and Michael Pratt

      Damien Neil added 1 comment

      File src/encoding/json/v2/arshal_funcs.go
      Line 167, Patchset 4:// Implementations must not return [errors.ErrUnsupported].
      Michael Pratt . unresolved

      Are Marshaler implementations allowed to return errors.ErrUnsupported? They don't say one way or another.

      Damien Neil

      Empirically, it appears that they are not. There's a check in makeMethodArshaler which converts ErrUnsupported into a "may not return errors.ErrUnsupported" error.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Joseph Tsai
      • Michael Pratt
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 6
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Comment-Date: Mon, 10 Aug 2026 22:43:17 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
      unsatisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      Aug 11, 2026, 10:36:35 AM (17 hours ago) Aug 11
      to Michael Pratt, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Joseph Tsai and Michael Pratt

      Michael Pratt uploaded new patchset

      Michael Pratt uploaded patch set #7 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Joseph Tsai
      • Michael Pratt
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 7
      unsatisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      Aug 11, 2026, 10:36:50 AM (17 hours ago) Aug 11
      to Michael Pratt, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, golang...@luci-project-accounts.iam.gserviceaccount.com, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
      Attention needed from Damien Neil and Joseph Tsai

      Michael Pratt voted and added 1 comment

      Votes added by Michael Pratt

      Commit-Queue+1

      1 comment

      File src/encoding/json/v2/arshal_funcs.go
      Line 167, Patchset 4:// Implementations must not return [errors.ErrUnsupported].
      Michael Pratt . resolved

      Are Marshaler implementations allowed to return errors.ErrUnsupported? They don't say one way or another.

      Damien Neil

      Empirically, it appears that they are not. There's a check in makeMethodArshaler which converts ErrUnsupported into a "may not return errors.ErrUnsupported" error.

      Michael Pratt

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Joseph Tsai
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
      Gerrit-Change-Number: 810320
      Gerrit-PatchSet: 7
      Gerrit-Owner: Michael Pratt <mpr...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Comment-Date: Tue, 11 Aug 2026 14:36:45 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
      Comment-In-Reply-To: Damien Neil <dn...@google.com>
      unsatisfied_requirement
      open
      diffy

      Joseph Tsai (Gerrit)

      unread,
      Aug 11, 2026, 2:07:21 PM (13 hours ago) Aug 11
      to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Jonathan Amsterdam, Damien Neil, golang-co...@googlegroups.com
      Attention needed from Damien Neil and Michael Pratt

      Joseph Tsai added 8 comments

      File src/encoding/json/v2/arshal_funcs.go
      Line 167, Patchset 7 (Latest):// Implementations must not retain or the value of T.
      Joseph Tsai . unresolved

      Drop "or"

      Line 254, Patchset 7 (Latest):// Implementations must not retain or the value of T.
      Joseph Tsai . unresolved

      Drop "or"

      File src/encoding/json/v2/arshal_methods.go
      Line 91, Patchset 7 (Latest):// types. [WithMarshalers] applies only to types other than the current type.
      Joseph Tsai . unresolved

      I'm not sure I understand what this sentence means.

      Line 96, Patchset 7 (Latest):
      Joseph Tsai . unresolved

      There's a blank line here that would break docs. Was this intentional?

      Line 97, Patchset 7 (Latest):// All other options are automatically handled outside of the MarshalerTo
      Joseph Tsai . unresolved

      "All" seems a bit strong. Should we instead say "Most"?

      Line 156, Patchset 7 (Latest):// types. [WithUnmarshalers] applies only to types other than the current type.
      Joseph Tsai . unresolved

      I'm not sure I understand what this sentence means.

      Line 161, Patchset 7 (Latest):
      Joseph Tsai . unresolved

      There's a blank line here that would break docs. Was this intentional?

      Line 162, Patchset 7 (Latest):// All other options are automatically handled outside of the UnmarshalerFrom
      Joseph Tsai . unresolved

      "All" seems a bit strong. Should we instead say "Most"?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Michael Pratt
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
        Gerrit-Change-Number: 810320
        Gerrit-PatchSet: 7
        Gerrit-Owner: Michael Pratt <mpr...@google.com>
        Gerrit-Reviewer: Damien Neil <dn...@google.com>
        Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
        Gerrit-Attention: Michael Pratt <mpr...@google.com>
        Gerrit-Attention: Damien Neil <dn...@google.com>
        Gerrit-Comment-Date: Tue, 11 Aug 2026 18:07:14 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Michael Pratt (Gerrit)

        unread,
        Aug 11, 2026, 5:02:58 PM (10 hours ago) Aug 11
        to Michael Pratt, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Damien Neil and Michael Pratt

        Michael Pratt uploaded new patchset

        Michael Pratt uploaded patch set #8 to this change.
        Following approvals got outdated and were removed:

        Related details

        Attention is currently required from:
        • Damien Neil
        • Michael Pratt
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: newpatchset
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
          Gerrit-Change-Number: 810320
          Gerrit-PatchSet: 8
          unsatisfied_requirement
          open
          diffy

          Michael Pratt (Gerrit)

          unread,
          Aug 11, 2026, 5:03:10 PM (10 hours ago) Aug 11
          to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Jonathan Amsterdam, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
          Attention needed from Damien Neil and Joseph Tsai

          Michael Pratt voted and added 8 comments

          Votes added by Michael Pratt

          Commit-Queue+1

          8 comments

          File src/encoding/json/v2/arshal_funcs.go
          Line 167, Patchset 7:// Implementations must not retain or the value of T.
          Joseph Tsai . resolved

          Drop "or"

          Michael Pratt

          Done

          Line 254, Patchset 7:// Implementations must not retain or the value of T.
          Joseph Tsai . resolved

          Drop "or"

          Michael Pratt

          Done

          File src/encoding/json/v2/arshal_methods.go
          Line 91, Patchset 7:// types. [WithMarshalers] applies only to types other than the current type.
          Joseph Tsai . unresolved

          I'm not sure I understand what this sentence means.

          Michael Pratt

          A bunch of options, like FormatNilSliceAsNull only apply to native Go types, so they are not relevant to MarshalerTo implementations [1].

          WithMarshalers applies to any Go type, so the previous sentence doesn't apply. But by definition, if MarshalJSONTo was called then WithMarshalers must not include a marshaler for this type (or it returned ErrUnsupported). Therefore WithMarshalers shouldn't matter to implementations, beyond being a motivation for calling MarshalEncode.

          I agree that this wording is really confusing. I've attempted to reword, but I'm still not thrilled with the wording. PTAL.

          [1] Well, if the type is a named slice, then maybe FormatNilSliceAsNull is relevant. Part of why I'm not a big fan of simplifying the docs.

          Line 96, Patchset 7:
          Joseph Tsai . resolved

          There's a blank line here that would break docs. Was this intentional?

          Michael Pratt

          Good catch, thanks!

          Line 97, Patchset 7:// All other options are automatically handled outside of the MarshalerTo
          Joseph Tsai . unresolved

          "All" seems a bit strong. Should we instead say "Most"?

          Michael Pratt

          I'm not sure I agree. If there are other options relevant to MarshalJSONTo implementations then they should be listed here. That's the point of this CL.

          "All other options" here means options not covered by the previous two paragraphs. But the previous paragraph no longer contains an exhaustive list, so it is certainly still vague.

          Line 156, Patchset 7:// types. [WithUnmarshalers] applies only to types other than the current type.
          Joseph Tsai . resolved

          I'm not sure I understand what this sentence means.

          Michael Pratt

          Acknowledged

          Line 161, Patchset 7:
          Joseph Tsai . resolved

          There's a blank line here that would break docs. Was this intentional?

          Michael Pratt

          Done

          Line 162, Patchset 7:// All other options are automatically handled outside of the UnmarshalerFrom
          Joseph Tsai . unresolved

          "All" seems a bit strong. Should we instead say "Most"?

          Michael Pratt

          See above.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Damien Neil
          • Joseph Tsai
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
          Gerrit-Change-Number: 810320
          Gerrit-PatchSet: 8
          Gerrit-Owner: Michael Pratt <mpr...@google.com>
          Gerrit-Reviewer: Damien Neil <dn...@google.com>
          Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
          Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
          Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
          Gerrit-Attention: Damien Neil <dn...@google.com>
          Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
          Gerrit-Comment-Date: Tue, 11 Aug 2026 21:03:06 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Joseph Tsai <joe...@digital-static.net>
          unsatisfied_requirement
          open
          diffy

          Damien Neil (Gerrit)

          unread,
          Aug 11, 2026, 8:16:39 PM (7 hours ago) Aug 11
          to Michael Pratt, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Jonathan Amsterdam, Joseph Tsai, golang-co...@googlegroups.com
          Attention needed from Joseph Tsai and Michael Pratt

          Damien Neil voted Code-Review+1

          Code-Review+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Joseph Tsai
          • Michael Pratt
          Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement satisfiedReview-Enforcement
            • requirement satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I714e8cddbd97bee02692b15cab662ffe6a6a6964
            Gerrit-Change-Number: 810320
            Gerrit-PatchSet: 8
            Gerrit-Owner: Michael Pratt <mpr...@google.com>
            Gerrit-Reviewer: Damien Neil <dn...@google.com>
            Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
            Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
            Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
            Gerrit-Attention: Michael Pratt <mpr...@google.com>
            Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
            Gerrit-Comment-Date: Wed, 12 Aug 2026 00:16:29 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy
            Reply all
            Reply to author
            Forward
            0 new messages