{"record":{"id":"cb110b8aa8025bd2","repo":"hyperledger/fabric","slug":"failed-to-get-transaction-context","errorCode":null,"errorMessage":"failed to get transaction context","messagePattern":"failed to get transaction context","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/handler.go","lineNumber":1118,"sourceCode":"\n\t// Get the chaincodeID to invoke. The chaincodeID to be called may\n\t// contain composite info like \"chaincode-name:version/channel-name\"\n\t// We are not using version now but default to the latest\n\ttargetInstance := ParseName(chaincodeSpec.ChaincodeId.Name)\n\n\t// If targetInstance is not an SCC, isValidTxSim should be called which will return an err.\n\t// We do not want to propagate calls to user CCs when the original call was to a SCC\n\t// without a channel context (ie, no ledger context).\n\tif !h.BuiltinSCCs.IsSysCC(targetInstance.ChaincodeName) {\n\t\t// normal path - UCC invocation with an empty (\"\") channel: isValidTxSim will return an error\n\t\treturn h.isValidTxSim(\"\", txid, \"could not get valid transaction\")\n\t}\n\n\t// Calling SCC without a ChannelID, then the assumption this is an external SCC called by the client (special case) and no UCC involved,\n\t// so no Transaction Simulator validation needed as there are no commits to the ledger, get the txContext directly if it is not nil\n\ttxContext := h.TXContexts.Get(channelID, txid)\n\tif txContext == nil {\n\t\treturn nil, errors.New(\"failed to get transaction context\")\n\t}\n\n\treturn txContext, nil\n}\n\nfunc (h *Handler) HandlePutState(msg *pb.ChaincodeMessage, txContext *TransactionContext) (*pb.ChaincodeMessage, error) {\n\tputState := &pb.PutState{}\n\tif err := proto.Unmarshal(msg.Payload, putState); err != nil {\n\t\treturn nil, errors.Wrap(err, \"unmarshal failed\")\n\t}\n\n\tif err := h.putState(putState, txContext); err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\treturn &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE, Txid: msg.Txid, ChannelId: msg.ChannelId}, nil\n}\n","sourceCodeStart":1100,"sourceCodeEnd":1136,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/handler.go#L1100-L1136","documentation":"HandleInvokeChaincode was called for a non-system chaincode but no valid transaction simulator/ledger context could be obtained for the channel+txid, so the invocation cannot execute against the ledger.","triggerScenarios":"Thrown at core/chaincode/handler.go:1118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the invocation carries a valid channel context (channel exists, txid not already cleaned up)","Retry the transaction; if persistent, check transaction-context lifecycle logs on the peer"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}