{"record":{"id":"2aff2eab4d7799ab","repo":"hyperledger/fabric","slug":"failed-to-execute-transaction-s","errorCode":null,"errorMessage":"failed to execute transaction %s","messagePattern":"failed to execute transaction (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/chaincode_support.go","lineNumber":175,"sourceCode":"\n\th, err := cs.Launch(ccid)\n\tif err != nil {\n\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","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/chaincode_support.go#L157-L193","documentation":"processChaincodeExecutionResult wraps any error returned from cs.Invoke (executing the chaincode transaction) with 'failed to execute transaction <txid>'. It is the top-level error users of the peer SDK/CLI see when a chaincode invocation fails anywhere between the peer dispatching the transaction and the chaincode returning a result. The wrapped cause contains the true failure (launch failure, auth error, chaincode error, timeout).","triggerScenarios":"Any error from ChaincodeSupport.Invoke during Execute/ExecuteLegacyInit: chaincode launch failure (see error 391), failed authentication of the chaincode stream, chaincode returned an ERROR message, or the transaction timed out waiting for the chaincode response.","commonSituations":"Endorsement failures surfacing as transaction execution errors when the chaincode logic returns an error; chaincode container unavailable/crashed; transaction timed out because chaincode was slow to start (cold start); wrong arguments causing chaincode panic or error response.","solutions":["Unwrap the cause in the error chain (it names the underlying problem, e.g. launch failure or chaincode error) and address that specific issue first.","If the cause is a chaincode error, inspect the chaincode logic/logs and fix the failing function or arguments in the invocation.","If the cause is a launch/connect failure, ensure the chaincode container is running and can reach the peer (see errors 391/392).","Increase chaincode.startuptimeout / request timeout if cold starts time out on first invocation."],"exampleFix":"// before: first invocation after deploy times out due to cold start\nconst result = await contract.submitTransaction('createAsset', 'a1');\n// after: perform a warm-up invoke or raise the peer's chaincode.startuptimeout\nawait contract.submitTransaction('initLedger'); // warm-up\nconst result = await contract.submitTransaction('createAsset', 'a1');","handlingStrategy":"try-catch","validationCode":"// Validate invocation inputs before submit\nif chaincodeName == \"\" || txArgs == nil {\n    return fmt.Errorf(\"invalid invocation: chaincode=%q args=%v\", chaincodeName, txArgs)\n}","typeGuard":"func IsTransactionExecutionError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to execute transaction\")\n}","tryCatchPattern":"try {\n    await contract.submitTransaction(\"createAsset\", \"a1\");\n} catch (e) {\n    if (String(e).includes(\"failed to execute transaction\")) {\n        // unwrap the cause in e.details / peer logs; handle chaincode vs launch failure differently\n        console.error(\"tx failed, cause:\", e.details);\n    }\n    throw e;\n}","preventionTips":["Always log the full error chain; the wrapped cause names the true failure.","Set adequate chaincode.startuptimeout for cold starts.","Test chaincode functions with realistic arguments before production invoke.","Monitor chaincode container health to catch launch/execution failures early."],"tags":["hyperledger-fabric","chaincode","transaction"],"backgroundTag":"transaction-execution-failed","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"}