hyperledger/fabric · error
query failed with status: %d - %s
Error message
query failed with status: %d - %s
What it means
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.
Source
Thrown at internal/peer/lifecycle/chaincode/querycommitted.go:137
if err != nil {
return errors.WithMessage(err, "failed to create signed proposal")
}
proposalResponse, err := c.EndorserClient.ProcessProposal(context.Background(), signedProposal)
if err != nil {
return errors.WithMessage(err, "failed to endorse proposal")
}
if proposalResponse == nil {
return errors.New("received nil proposal response")
}
if proposalResponse.Response == nil {
return errors.New("received proposal response with nil response")
}
if proposalResponse.Response.Status != int32(cb.Status_SUCCESS) {
return errors.Errorf("query failed with status: %d - %s", proposalResponse.Response.Status, proposalResponse.Response.Message)
}
if strings.ToLower(c.Input.OutputFormat) == "json" {
return c.printResponseAsJSON(proposalResponse)
}
return c.printResponse(proposalResponse)
}
func (c *CommittedQuerier) printResponseAsJSON(proposalResponse *pb.ProposalResponse) error {
if c.Input.Name != "" {
return printResponseAsJSON(proposalResponse, &lb.QueryChaincodeDefinitionResult{}, c.Writer)
}
return printResponseAsJSON(proposalResponse, &lb.QueryChaincodeDefinitionsResult{}, c.Writer)
}
// printResponse prints the information included in the response
// from the server as human readable plain-text.
func (c *CommittedQuerier) printResponse(proposalResponse *pb.ProposalResponse) error {View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before peer lifecycle chaincode querycommitted --channelID mychannel --name wrongcc // error: query failed with status: 500 - chaincode 'wrongcc' not defined // after peer lifecycle chaincode querycommitted --channelID mychannel // list first, then query a committed name
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check identity and channel membership before querying // ensure peer is joined: peer channel list shows the target channel // ensure chaincode is committed: query list form without --name first
Try / catch
if err := q.Query(); err != nil {
var statusErr *statusError // or parse message
if m := regexp.MustCompile(`status: (\d+) - (.*)`).FindStringSubmatch(err.Error()); m != nil {
return fmt.Errorf("peer rejected query (status %s): %s", m[1], m[2])
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- id cannot be nil if buf is not nil
- depspec cannot be nil if buf is not nil
- received proposal response with nil response
- query failed with status: %d - %s
- query iterator not found
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/bc5cf1935ed9d442.
Report an issue: GitHub.