{"record":{"id":"153f0a7bde872d5d","repo":"hyperledger/fabric","slug":"execute-failed","errorCode":null,"errorMessage":"execute failed","messagePattern":"execute failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/handler.go","lineNumber":1407,"sourceCode":"\t\tsim, err := lgr.NewTxSimulator(msg.Txid)\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithStack(err)\n\t\t}\n\t\tdefer sim.Done()\n\n\t\thqe, err := lgr.NewHistoryQueryExecutor()\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithStack(err)\n\t\t}\n\n\t\ttxParams.TXSimulator = sim\n\t\ttxParams.HistoryQueryExecutor = hqe\n\t}\n\n\t// Execute the chaincode... this CANNOT be an init at least for now\n\tresponseMessage, err := h.Invoker.Invoke(txParams, targetInstance.ChaincodeName, chaincodeSpec.Input)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"execute failed\")\n\t}\n\tif responseMessage == nil {\n\t\treturn nil, errors.New(\"marshal failed: proto: Marshal called with nil\")\n\t}\n\n\t// payload is marshalled and sent to the calling chaincode's shim which unmarshals and\n\t// sends it to chaincode\n\tres, err := proto.Marshal(responseMessage)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"marshal failed\")\n\t}\n\n\treturn &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE, Payload: res, Txid: msg.Txid, ChannelId: msg.ChannelId}, nil\n}\n\nfunc (h *Handler) Execute(txParams *ccprovider.TransactionParams, namespace string, msg *pb.ChaincodeMessage, timeout time.Duration) (*pb.ChaincodeMessage, error) {\n\tchaincodeLogger.Debugf(\"Entry\")\n\tdefer chaincodeLogger.Debugf(\"Exit\")","sourceCodeStart":1389,"sourceCodeEnd":1425,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/handler.go#L1389-L1425","documentation":"Wraps any error returned by h.Invoker.Invoke during a chaincode-to-chaincode (or user) transaction execution in the peer's handler. It indicates the target chaincode's Invoke failed to execute at all — the wrapped cause carries the real reason (shim error, transaction failure, internal error).","triggerScenarios":"h.Invoker.Invoke(txParams, targetInstance.ChaincodeName, chaincodeSpec.Input) returns a non-nil error during ExecuteChaincode / Execute processing of a transaction message.","commonSituations":"Target chaincode returns an error from its Invoke path; chaincode container crashed mid-invocation; invalid invocation arguments; internal state/ledger errors during simulation.","solutions":["Inspect the wrapped (inner) error in the chain for the root cause.","Check the target chaincode's logs for the failure during the invocation.","Validate the ChaincodeSpec.Input arguments and chaincode name in the calling code.","Confirm the target chaincode container is running and healthy (peer chaincode list, docker ps / kubectl)."],"exampleFix":"// Go caller-side handling\nif err != nil {\n    if strings.Contains(err.Error(), \"execute failed\") {\n        log.Printf(\"chaincode invoke failed: %v\", errors.Unwrap(err))\n    }\n}\n// fix usually lives in the target chaincode: return a proper error message\nreturn shim.Error(\"invalid key\")","handlingStrategy":"try-catch","validationCode":"// validate target chaincode name and args before invoking\nif ccName == \"\" || len(args) == 0 {\n    return shim.Error(\"invalid invoke target\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    return shim.Error(fmt.Sprintf(\"chaincode invoke failed: %v\", errors.Unwrap(err)))\n}","preventionTips":["Always check the inner/wrapped error for the real cause.","Monitor target chaincode container logs for invoke-time failures.","Write integration tests for every cross-chaincode call path."],"tags":["hyperledger-fabric","chaincode","invocation","wrapped-error"],"backgroundTag":"chaincode-invoke-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"}