{"record":{"id":"922f36ef896071ae","repo":"hyperledger/fabric","slug":"not-found-922f36","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"discovery/client/api.go","lineNumber":18,"sourceCode":"/*\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n*/\n\npackage discovery\n\nimport (\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/discovery\"\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/peer\"\n\t\"github.com/hyperledger/fabric/gossip/protoext\"\n\t\"github.com/pkg/errors\"\n\t\"google.golang.org/grpc\"\n)\n\n// ErrNotFound defines an error that means that an element wasn't found\nvar ErrNotFound = errors.New(\"not found\")\n\n// Signer signs a message and returns the signature and nil,\n// or nil and error on failure\ntype Signer func(msg []byte) ([]byte, error)\n\n// Dialer connects to the server\ntype Dialer func() (*grpc.ClientConn, error)\n\n// Response aggregates several responses from the discovery service\ntype Response interface {\n\t// ForChannel returns a ChannelResponse in the context of a given channel\n\tForChannel(string) ChannelResponse\n\n\t// ForLocal returns a LocalResponse in the context of no channel\n\tForLocal() LocalResponse\n}\n\n// ChannelResponse aggregates responses for a given channel","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/client/api.go#L1-L36","documentation":"ErrNotFound in discovery/client/api.go:18 is a sentinel error (errors.New(\"not found\")) meaning an element wasn't found. The discovery client's Get, Config, parsePeers, and Endorsers return it when a requested element does not exist in the response. It is distinct from LevelDB's leveldb.ErrNotFound, which the ledger helper translates into a nil value, not an application error.","triggerScenarios":"Calling client.Get/Config/Endorsers when the discovery response contains no matching element (e.g. no peers satisfy the request, channel not found, peer has no ledger for the channel), hitting the `return nil, ErrNotFound` branch in discovery/client/client.go:215.","commonSituations":"Querying a channel the peer isn't joined to; discovery service has no membership data yet; asking for endorsers of a chaincode not installed on any peer; typo'd chaincode name.","solutions":["Check errors.Is(err, discovery.ErrNotFound) to detect this sentinel and handle it as 'no data', not a hard failure","Verify the channel name and chaincode name are correct and that the peer has joined the channel","Ensure the peer has the discovery service enabled and the chaincode installed/committed on at least one peer","Retry after peers finish gossip membership sync if the network just started"],"exampleFix":"// before: treating any error as fatal\nresp, err := client.Send(ctx, req, auth)\nif err != nil { return err }\n\n// after: handle not-found distinctly\nif errors.Is(err, discovery.ErrNotFound) {\n    return nil, nil // element genuinely absent\n}","handlingStrategy":"type-guard","validationCode":"if err != nil && errors.Is(err, discovery.ErrNotFound) {\n    // element absent: channel not joined, chaincode not installed, etc.\n}","typeGuard":"func isNotFound(err error) bool { return errors.Is(err, discovery.ErrNotFound) }","tryCatchPattern":"peers, err := client.Send(ctx, req, auth)\nif isNotFound(err) {\n    return nil, nil // handle absence gracefully\n}\nif err != nil {\n    return nil, err\n}","preventionTips":["Confirm the peer has joined the channel and installed the chaincode before querying discovery","Use errors.Is with the sentinel instead of string comparison","Wait for gossip membership convergence on fresh networks"],"tags":["hyperledger-fabric","discovery-client","sentinel-error","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}