Skip to content

fix(fabric): keep the error type when collecting an endorsement fails - #2585

Merged
mbrandenburger merged 3 commits into
hyperledger-labs:mainfrom
SaidAltury-ibm:fix/2557-endorsement-error-types
Nov 10, 2026
Merged

mbrandenburger merged 3 commits into
hyperledger-labs:mainfrom
SaidAltury-ibm:fix/2557-endorsement-error-types

Conversation

@SaidAltury-ibm

@SaidAltury-ibm SaidAltury-ibm commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An application that spreads its endorsements over several endorser nodes needs to tell an endorser that is unavailable (draining, busy, closed, too slow) from any other failure, so that it tries the next endorser only in the first case. collectEndorsementsView, which state.NewCollectEndorsementsView wraps, lost that information for three of its failures, so errors.Is(err, session.ErrDraining) and the like never matched in the caller.

Fixes #2557. Unblocks #2558.

Investigation

Every error the view returns for a remote party, and whether a caller could match it:

Failure On main With this PR
The party rejected the session errors.New(payload), untyped wraps session.ErrRejected and the reason's sentinel (ErrDraining, ErrBusy, ErrUnknownView), as session.RejectionError does
The session closed before the answer untyped wraps comm.ErrSessionClosed
No answer within the one-minute wait untyped wraps context.DeadlineExceeded
The view's context ended wraps the context's error unchanged
The send failed, e.g. the endorser is down wraps the dial error (syscall.ECONNREFUSED, *net.OpError) unchanged
An error reply that is not a rejection, an endorsement that does not verify, a local failure wraps nothing unchanged

The view is shared by Fabric and Fabric-x apps, so both are covered.

NewParallelCollectEndorsementsOnProposalView, which the issue asks to check, already returns typed rejections: it receives through the JSON session, which calls session.RejectionError. Its timeout (time out reached on session) and closed session (received message is nil) are untyped too, but both come from the shared JSON session in platform/view/services/comm/session/json.go, which many views use, and #2558 does not use this view. They are left out of this PR.

Changes

  • platform/fabric/services/endorser/endorsement.go:
    • a rejection reply wraps session.RejectionError's error; any other error reply wraps nothing;
    • a closed session wraps comm.ErrSessionClosed, and the timeout wraps context.DeadlineExceeded, the existing sentinel rather than a new one;
    • NewCollectEndorsementsView gains a godoc listing the errors a caller can match. It also says that each endorsement is added to the transaction as soon as it verifies, this node's own included, and that a failure does not remove those added before it, while a party that fails before its reply verifies adds nothing;
    • each error keeps the text it has on main: a small local textError carries the old text and unwraps to the sentinel;
    • the local session variables are renamed (s and sess), since they would shadow the imported package.
  • platform/fabric/services/state/endorsement.go: the wrapper's godoc points to that list.
  • docs/platform/fabric/fabric-sdk.md: a "Collecting endorsements" section with the same table, and when a failed attempt leaves the transaction as it was: a caller that asks one party at a time can pass the same transaction to another party.

The errors gain types; their texts are the same as on main, so log searches and callers that match on text keep working. Not breaking.

Testing

TestCollectEndorsementsView_ErrorTypes (platform/fabric/services/endorser/endorsement_test.go) runs the view on newCollectFixture, whose session reply each subtest controls. The timeout subtest builds the fixture in a testing/synctest bubble, so the one-minute wait passes at once. The rejection subtest also checks that the rejected party added nothing to the transaction. The view's context ending is covered by the existing TestCollectEndorsementsView_ReturnsWhenContextEnds.

Subtest Without the fix With the fix
rejection: draining, busy, node_busy, unknown_view, and nothing appended fails pass
session closed fails pass
no reply before the timeout fails pass
error reply that is not a rejection: the text is the payload, and it is not ErrRejected pass pass
  • go test -race -count=3 -shuffle=on on platform/fabric/services/endorser and platform/fabric/services/state: pass
  • go test ./platform/fabric/services/...: pass
  • make checks: 0 issues

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Hey @SaidAltury-ibm 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

✅ DCO Sign-off -- All commits have valid sign-offs. Nice work!


❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:

  • d7926d7 fix(fabric): keep the error type when collecting an endorsement fails
  • e98454b fixup! fix(fabric): keep the error type when collecting an endorsement fails
  • 1d7d6c1 fixup! fix(fabric): keep the error type when collecting an endorsement fails

You'll need to sign your commits with GPG (e.g. git commit -S). See the Signing Guide for a step-by-step walkthrough.


✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing!


✅ Issue Link -- Linked to #2557 (assigned to you).


⏳ All checks must pass before this PR can be reviewed. You've got this!

@github-actions github-actions Bot added the status: needs review The pull request is ready for maintainer review label Nov 10, 2026
@SaidAltury-ibm SaidAltury-ibm added this to the 26Q4 milestone Nov 10, 2026

@mbrandenburger mbrandenburger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SaidAltury-ibm for working on this. Please see my comments below.

Comment thread docs/platform/fabric/fabric-sdk.md Resolved
@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@github-actions github-actions Bot added status: needs revision The pull request requires changes from the author before it can be reviewed or merged and removed status: needs review The pull request is ready for maintainer review labels Nov 10, 2026
@mbrandenburger
mbrandenburger enabled auto-merge (squash) November 10, 2026 16:43

@mbrandenburger mbrandenburger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SaidAltury-ibm

SaidAltury-ibm and others added 3 commits November 10, 2026 17:44
An application that spreads its endorsements over several endorser nodes
needs to tell an endorser that is unavailable from any other failure. The
collect-endorsements view lost that information: a rejection reply became
a plain error with the payload as text, and a closed session and the
one-minute timeout wrapped nothing.

A rejection now returns session.RejectionError's error, which wraps
session.ErrRejected and the reason's sentinel, such as
session.ErrDraining. A closed session wraps comm.ErrSessionClosed, and the
timeout wraps context.DeadlineExceeded. The godoc of
NewCollectEndorsementsView and the Fabric SDK docs list the errors a
caller can match.

Fixes hyperledger-labs#2557

Signed-off-by: Said Altury <Said.Altury@ibm.com>
…t fails

Signed-off-by: Said Altury <Said.Altury@ibm.com>
…t fails

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger
mbrandenburger force-pushed the fix/2557-endorsement-error-types branch from 0283f78 to 1d7d6c1 Compare November 10, 2026 16:44
@mbrandenburger
mbrandenburger merged commit b634f35 into hyperledger-labs:main Nov 10, 2026
57 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix status: needs revision The pull request requires changes from the author before it can be reviewed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(fabric): keep the error type when collecting an endorsement fails

2 participants