{"record":{"id":"66dd5f5d63091f27","repo":"hyperledger/fabric","slug":"nil-response-from-transaction-s","errorCode":null,"errorMessage":"nil response from transaction %s","messagePattern":"nil response from transaction (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/chaincode_support.go","lineNumber":178,"sourceCode":"\t\treturn nil, nil, err\n\t}\n\n\tresp, err := cs.execute(pb.ChaincodeMessage_INIT, txParams, ccName, input, h)\n\treturn processChaincodeExecutionResult(txParams.TxID, ccName, resp, err)\n}\n\n// Execute invokes chaincode and returns the original response.\nfunc (cs *ChaincodeSupport) Execute(txParams *ccprovider.TransactionParams, chaincodeName string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error) {\n\tresp, err := cs.Invoke(txParams, chaincodeName, input)\n\treturn processChaincodeExecutionResult(txParams.TxID, chaincodeName, resp, err)\n}\n\nfunc processChaincodeExecutionResult(txid, ccName string, resp *pb.ChaincodeMessage, err error) (*pb.Response, *pb.ChaincodeEvent, error) {\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrapf(err, \"failed to execute transaction %s\", txid)\n\t}\n\tif resp == nil {\n\t\treturn nil, nil, errors.Errorf(\"nil response from transaction %s\", txid)\n\t}\n\n\tif resp.ChaincodeEvent != nil {\n\t\tresp.ChaincodeEvent.ChaincodeId = ccName\n\t\tresp.ChaincodeEvent.TxId = txid\n\t}\n\n\tswitch resp.Type {\n\tcase pb.ChaincodeMessage_COMPLETED:\n\t\tres := &pb.Response{}\n\t\terr := proto.Unmarshal(resp.Payload, res)\n\t\tif err != nil {\n\t\t\treturn nil, nil, errors.Wrapf(err, \"failed to unmarshal response for transaction %s\", txid)\n\t\t}\n\t\treturn res, resp.ChaincodeEvent, nil\n\n\tcase pb.ChaincodeMessage_ERROR:\n\t\treturn nil, resp.ChaincodeEvent, errors.Errorf(\"transaction returned with failure: %s\", resp.Payload)","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/chaincode_support.go#L160-L196","documentation":"processChaincodeExecutionResult raises this when the Invoke call returned no error but also no ChaincodeMessage response (resp == nil). The peer expected a well-formed chaincode response message to convert into a pb.Response; a nil response means the execution produced nothing usable, which the peer treats as a hard error for the transaction.","triggerScenarios":"cs.Invoke returns (nil, nil): an internal path where the chaincode handler completed without delivering a response message — e.g. handler state inconsistencies, chaincode shutting down mid-invocation, or unexpected success-with-no-message from the internal execute path.","commonSituations":"Chaincode container terminating during the invocation so the response is lost; system/in-process chaincode that returns without emitting a response message; rare internal races in the handler registry during concurrent transactions on the same chaincode.","solutions":["Check peer and chaincode logs around the txid for a container exit or handler teardown that dropped the response.","Retry the transaction; transient races or mid-invocation container death usually do not recur once the chaincode is healthy.","Redeploy/fix the chaincode if its process exits during execution (OOM, panic), ensuring responses are always emitted.","If reproducible with a system chaincode, check that chaincode's registration and execute path for a bug and report/patch it."],"exampleFix":"// before: chaincode function can return without emitting a response when a resource is missing\nfunc (s *SmartContract) GetAsset(ctx, id string) { if id == \"\" { return } ... }\n// after: always return a response or an explicit error\nfunc (s *SmartContract) GetAsset(ctx, id string) (*Asset, error) {\n    if id == \"\" { return nil, fmt.Errorf(\"id required\") }\n    ...\n}","handlingStrategy":"type-guard","validationCode":"// Ensure chaincode functions always return a value or error, never fall through silently\n// go vet / staticcheck on chaincode to catch missing return paths","typeGuard":"func IsNilResponseError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"nil response from transaction\")\n}","tryCatchPattern":"resp, err := contract.EvaluateTransaction(\"readAsset\", \"a1\")\nif err != nil {\n    if IsNilResponseError(err) {\n        // retry once; often caused by a transient handler/container race\n        resp, err = contract.EvaluateTransaction(\"readAsset\", \"a1\")\n    }\n    return resp, err\n}","preventionTips":["Ensure every chaincode function path returns a response or explicit error.","Guard against OOM/panics that kill the chaincode mid-invocation.","Add panic recovery in chaincode so a recovered panic still emits an error response.","Test chaincode with edge-case inputs to catch silent no-return paths."],"tags":["hyperledger-fabric","chaincode","nil-response"],"backgroundTag":"nil-chaincode-response","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"}