[go] errors: fix errors.Join single unwrappable errors

1 view
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Dec 23, 2025, 12:44:42 AM (yesterday) Dec 23
to goph...@pubsubhelper.golang.org, Andrei Rusakov, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

errors: fix errors.Join single unwrappable errors

Fixes #76961 mismatch between the new behavior and the function documentation.
Change-Id: I8600aa1d410fa8ef301807ed001955199f7360d2
GitHub-Last-Rev: a672590cd80388b9567a18de1efe432a3dec477c
GitHub-Pull-Request: golang/go#76963

Change diff

diff --git a/src/errors/join.go b/src/errors/join.go
index 08a7986..92b2cf4 100644
--- a/src/errors/join.go
+++ b/src/errors/join.go
@@ -29,9 +29,7 @@
}
if n == 1 {
for _, err := range errs {
- if _, ok := err.(interface {
- Unwrap() []error
- }); ok {
+ if _, ok := err.(*joinError); ok {
return err
}
}
diff --git a/src/errors/join_test.go b/src/errors/join_test.go
index 439b372..91694f8 100644
--- a/src/errors/join_test.go
+++ b/src/errors/join_test.go
@@ -104,3 +104,24 @@
})
}
}
+
+func TestJoin_returns_wrapped_error(t *testing.T) {
+ var x CustomUnwrappableError
+ if errors.Join(x) == error(x) { // Actually this comparison panics.
+ t.Errorf("Join(x) returns x, expected to return a wrapped error")
+ }
+}
+
+type CustomUnwrappableError []error
+
+func (c CustomUnwrappableError) Error() (s string) {
+ for i, err := range c {
+ if i > 0 {
+ s += "\n"
+ }
+ s += err.Error()
+ }
+ return s
+}
+
+func (c CustomUnwrappableError) Unwrap() []error { return c }

Change information

Files:
  • M src/errors/join.go
  • M src/errors/join_test.go
Change size: S
Delta: 2 files changed, 22 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: master
Gerrit-Change-Id: I8600aa1d410fa8ef301807ed001955199f7360d2
Gerrit-Change-Number: 732080
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Andrei Rusakov <psih...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Dec 23, 2025, 12:44:44 AM (yesterday) Dec 23
to Andrei Rusakov, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
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: I8600aa1d410fa8ef301807ed001955199f7360d2
    Gerrit-Change-Number: 732080
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Andrei Rusakov <psih...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 23 Dec 2025 05:44:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    Dec 23, 2025, 12:46:46 AM (yesterday) Dec 23
    to Andrei Rusakov, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Message from Gopher Robot

    Congratulations on opening your first change. Thank you for your contribution!

    Next steps:
    A maintainer will review your change and provide feedback. See
    https://go.dev/doc/contribute#review for more info and tips to get your
    patch through code review.

    Most changes in the Go project go through a few rounds of revision. This can be
    surprising to people new to the project. The careful, iterative review process
    is our way of helping mentor contributors and ensuring that their contributions
    have a lasting impact.

    During May-July and Nov-Jan the Go project is in a code freeze, during which
    little code gets reviewed or merged. If a reviewer responds with a comment like
    R=go1.11 or adds a tag like "wait-release", it means that this CL will be
    reviewed as part of the next development cycle. See https://go.dev/s/release
    for more details.

    Open in Gerrit

    Related details

    Attention set is empty
    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: I8600aa1d410fa8ef301807ed001955199f7360d2
    Gerrit-Change-Number: 732080
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Andrei Rusakov <psih...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 23 Dec 2025 05:46:42 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Andrei Rusakov (Gerrit)

    unread,
    Dec 23, 2025, 1:18:54 AM (yesterday) Dec 23
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Dmitri Shuralyov, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Damien Neil, Dmitri Shuralyov and Ian Lance Taylor

    Andrei Rusakov added 1 comment

    Patchset-level comments
    Gopher Robot . resolved

    I spotted some possible problems with your PR:

      1. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

    Please address any problems by updating the GitHub PR.

    When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

    To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

    For more details, see:

    (In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

    Andrei Rusakov

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Dmitri Shuralyov
    • Ian Lance Taylor
    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: I8600aa1d410fa8ef301807ed001955199f7360d2
      Gerrit-Change-Number: 732080
      Gerrit-PatchSet: 1
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-CC: Andrei Rusakov <psih...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-Attention: Dmitri Shuralyov <dmit...@golang.org>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Comment-Date: Tue, 23 Dec 2025 06:18:45 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gopher Robot <go...@golang.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Gerrit Bot (Gerrit)

      unread,
      Dec 23, 2025, 1:33:45 AM (yesterday) Dec 23
      to Andrei Rusakov, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Dmitri Shuralyov and Ian Lance Taylor

      Gerrit Bot uploaded new patchset

      Gerrit Bot uploaded patch set #2 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Dmitri Shuralyov
      • Ian Lance Taylor
      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: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I8600aa1d410fa8ef301807ed001955199f7360d2
      Gerrit-Change-Number: 732080
      Gerrit-PatchSet: 2
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages