{"record":{"id":"bc5cf1935ed9d442","repo":"hyperledger/fabric","slug":"query-failed-with-status-d-s-bc5cf1","errorCode":null,"errorMessage":"query failed with status: %d - %s","messagePattern":"query failed with status: (.+?) - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/querycommitted.go","lineNumber":137,"sourceCode":"\tif err != nil {\n\t\treturn errors.WithMessage(err, \"failed to create signed proposal\")\n\t}\n\n\tproposalResponse, err := c.EndorserClient.ProcessProposal(context.Background(), signedProposal)\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"failed to endorse proposal\")\n\t}\n\n\tif proposalResponse == nil {\n\t\treturn errors.New(\"received nil proposal response\")\n\t}\n\n\tif proposalResponse.Response == nil {\n\t\treturn errors.New(\"received proposal response with nil response\")\n\t}\n\n\tif proposalResponse.Response.Status != int32(cb.Status_SUCCESS) {\n\t\treturn errors.Errorf(\"query failed with status: %d - %s\", proposalResponse.Response.Status, proposalResponse.Response.Message)\n\t}\n\n\tif strings.ToLower(c.Input.OutputFormat) == \"json\" {\n\t\treturn c.printResponseAsJSON(proposalResponse)\n\t}\n\treturn c.printResponse(proposalResponse)\n}\n\nfunc (c *CommittedQuerier) printResponseAsJSON(proposalResponse *pb.ProposalResponse) error {\n\tif c.Input.Name != \"\" {\n\t\treturn printResponseAsJSON(proposalResponse, &lb.QueryChaincodeDefinitionResult{}, c.Writer)\n\t}\n\treturn printResponseAsJSON(proposalResponse, &lb.QueryChaincodeDefinitionsResult{}, c.Writer)\n}\n\n// printResponse prints the information included in the response\n// from the server as human readable plain-text.\nfunc (c *CommittedQuerier) printResponse(proposalResponse *pb.ProposalResponse) error {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/querycommitted.go#L119-L155","documentation":"After confirming a non-nil Response, Query checks the response status against cb.Status_SUCCESS (200). A non-success status means the peer explicitly rejected or failed the _lifecycle QueryChaincodeDefinition(s) invocation. The error message embeds the peer-supplied status code and message.","triggerScenarios":"Peer-side failure of the _lifecycle querycommitted invocation: unknown chaincode name, access denied, channel does not exist on the peer, or internal endorser error — any case where Response.Status != 200.","commonSituations":"Querying a chaincode name that is not committed on the channel; wrong --channelID; the peer is not joined to the channel; TLS/ACL misconfiguration denying the caller.","solutions":["Read the embedded status and message from the error to identify the peer-side cause","Confirm the chaincode is committed: run querycommitted without --name to list all definitions","Verify --channelID matches a channel the peer has joined","Check peer logs for the underlying endorsement error","Verify caller identity satisfies the channel's lifecycle endorser ACL"],"exampleFix":"// before\npeer lifecycle chaincode querycommitted --channelID mychannel --name wrongcc\n// error: query failed with status: 500 - chaincode 'wrongcc' not defined\n// after\npeer lifecycle chaincode querycommitted --channelID mychannel  // list first, then query a committed name","handlingStrategy":"try-catch","validationCode":"// pre-check identity and channel membership before querying\n// ensure peer is joined: peer channel list shows the target channel\n// ensure chaincode is committed: query list form without --name first","typeGuard":null,"tryCatchPattern":"if err := q.Query(); err != nil {\n    var statusErr *statusError // or parse message\n    if m := regexp.MustCompile(`status: (\\d+) - (.*)`).FindStringSubmatch(err.Error()); m != nil {\n        return fmt.Errorf(\"peer rejected query (status %s): %s\", m[1], m[2])\n    }\n    return err\n}","preventionTips":["Verify --channelID and --name against an unfiltered querycommitted listing first","Confirm the peer has joined the target channel","Check lifecycle endorser ACLs for your organization's MSP","Keep CLI and peer Fabric versions aligned"],"tags":["fabric","lifecycle","chaincode","endorsement-status"],"backgroundTag":"query-failed-status","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"}