[go] encoding/json/jsontext: clarify safety of AvailableBuffer

3 views
Skip to first unread message

Michael Pratt (Gerrit)

unread,
Aug 6, 2026, 3:13:15 PM (yesterday) Aug 6
to Michael Pratt, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, Joseph Tsai, Damien Neil, golang-co...@googlegroups.com
Attention needed from Damien Neil, Jonathan Amsterdam and Joseph Tsai

Michael Pratt voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • Jonathan Amsterdam
  • 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: I12ab3ea4e858860f8a241c514a883d376a6a6964
Gerrit-Change-Number: 811780
Gerrit-PatchSet: 1
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 19:13:11 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Jonathan Amsterdam (Gerrit)

unread,
Aug 6, 2026, 4:50:52 PM (yesterday) Aug 6
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 Code-Review+2

Code-Review+2
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: I12ab3ea4e858860f8a241c514a883d376a6a6964
Gerrit-Change-Number: 811780
Gerrit-PatchSet: 1
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: Joseph Tsai <joe...@digital-static.net>
Gerrit-Comment-Date: Thu, 06 Aug 2026 20:50:49 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Damien Neil (Gerrit)

unread,
Aug 6, 2026, 8:48:28 PM (yesterday) Aug 6
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 voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • 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: I12ab3ea4e858860f8a241c514a883d376a6a6964
Gerrit-Change-Number: 811780
Gerrit-PatchSet: 1
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: Fri, 07 Aug 2026 00:48:20 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Michael Pratt (Gerrit)

unread,
11:28 AM (11 hours ago) 11:28 AM
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 #2 to this change.
Following approvals got outdated and were removed:
Open in Gerrit

Related details

Attention is currently required from:
  • Joseph Tsai
  • Michael Pratt
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement 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: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Gerrit-Change-Number: 811780
    Gerrit-PatchSet: 2
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Michael Pratt (Gerrit)

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

    Michael Pratt voted Commit-Queue+1

    Commit-Queue+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joseph Tsai
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement 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: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Gerrit-Change-Number: 811780
    Gerrit-PatchSet: 2
    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: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Comment-Date: Fri, 07 Aug 2026 15:28:37 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Michael Pratt (Gerrit)

    unread,
    1:01 PM (10 hours ago) 1:01 PM
    to Michael Pratt, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Damien Neil, Jonathan Amsterdam, Joseph Tsai, golang-co...@googlegroups.com

    Michael Pratt submitted the change

    Unreviewed changes

    1 is the latest approved patch-set.
    No files were changed between the latest approved patch-set and the submitted one.

    Change information

    Commit message:
    encoding/json/jsontext: clarify safety of AvailableBuffer

    The current wording makes it sound like the buffer itself is unsafe, but
    this is just trying to warn that manually constructing a Value is
    error-prone.

    For #71497.
    Change-Id: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Reviewed-by: Jonathan Amsterdam <j...@google.com>
    Reviewed-by: Damien Neil <dn...@google.com>
    Files:
    • M src/encoding/json/jsontext/encode.go
    Change size: XS
    Delta: 1 file changed, 3 insertions(+), 3 deletions(-)
    Branch: refs/heads/master
    Submit Requirements:
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Gerrit-Change-Number: 811780
    Gerrit-PatchSet: 3
    open
    diffy
    satisfied_requirement

    Michael Pratt (Gerrit)

    unread,
    1:01 PM (10 hours ago) 1:01 PM
    to goph...@pubsubhelper.golang.org, Michael Pratt, golang-co...@googlegroups.com

    Michael Pratt has uploaded the change for review

    Commit message

    [release-branch.go1.27] encoding/json/jsontext: clarify safety of AvailableBuffer


    The current wording makes it sound like the buffer itself is unsafe, but
    this is just trying to warn that manually constructing a Value is
    error-prone.

    For #71497.

    Change-Id: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Reviewed-on: https://go-review.googlesource.com/c/go/+/811780
    Reviewed-by: Jonathan Amsterdam <j...@google.com>
    Reviewed-by: Damien Neil <dn...@google.com>
    LUCI-TryBot-Result: golang...@luci-project-accounts.iam.gserviceaccount.com <golang...@luci-project-accounts.iam.gserviceaccount.com>
    (cherry picked from commit 35a7a64d0fef48dadd0af07c1f8e6f46ec770bc0)

    Change diff

    diff --git a/src/encoding/json/jsontext/encode.go b/src/encoding/json/jsontext/encode.go
    index 116e150..047b00a 100644
    --- a/src/encoding/json/jsontext/encode.go
    +++ b/src/encoding/json/jsontext/encode.go
    @@ -913,9 +913,9 @@
    // b = append(b, '"')
    // ... := e.WriteValue(b)
    //
    -// WriteValue expects a JSON value. Using AvailableBuffer to manually construct
    -// a value requires caution to avoid producing an invalid JSON value that would
    -// then cause WriteValue to fail.
    +// Note that WriteValue expects a valid JSON value. Constructing a value in a
    +// raw []byte requires more care than using constructor functions like
    +// [String], which always return valid [Token]s or [Value]s.
    func (e *Encoder) AvailableBuffer() []byte {
    // NOTE: We don't return e.Buf[len(e.Buf):cap(e.Buf)] since WriteValue would
    // need to take special care to avoid mangling the data while reformatting.

    Change information

    Files:
    • M src/encoding/json/jsontext/encode.go
    Change size: XS
    Delta: 1 file changed, 3 insertions(+), 3 deletions(-)
    Open in Gerrit

    Related details

    Attention set is empty
    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: newchange
    Gerrit-Project: go
    Gerrit-Branch: release-branch.go1.27
    Gerrit-Change-Id: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Gerrit-Change-Number: 811960
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Michael Pratt (Gerrit)

    unread,
    1:02 PM (10 hours ago) 1:02 PM
    to Michael Pratt, goph...@pubsubhelper.golang.org, Jonathan Amsterdam, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil and Jonathan Amsterdam

    Michael Pratt voted and added 1 comment

    Votes added by Michael Pratt

    Commit-Queue+1

    1 comment

    Patchset-level comments
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Jonathan Amsterdam
    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: release-branch.go1.27
    Gerrit-Change-Id: I12ab3ea4e858860f8a241c514a883d376a6a6964
    Gerrit-Change-Number: 811960
    Gerrit-PatchSet: 1
    Gerrit-Owner: Michael Pratt <mpr...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Jonathan Amsterdam <j...@google.com>
    Gerrit-Comment-Date: Fri, 07 Aug 2026 17:02:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages