{"record":{"id":"617978ddcc219f6a","repo":"hyperledger/fabric","slug":"transaction-invalidated-with-status-s","errorCode":null,"errorMessage":"transaction invalidated with status (%s)","messagePattern":"transaction invalidated with status \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/chaincode/common.go","lineNumber":739,"sourceCode":"// ClientWait waits for the specified deliver client to receive\n// a block event with the requested txid\nfunc (dg *DeliverGroup) ClientWait(dc *DeliverClient) {\n\tdefer dg.wg.Done()\n\tfor {\n\t\tresp, err := dc.Connection.Recv()\n\t\tif err != nil {\n\t\t\terr = errors.WithMessagef(err, \"error receiving from deliver filtered at %s\", dc.Address)\n\t\t\tdg.setError(err)\n\t\t\treturn\n\t\t}\n\t\tswitch r := resp.Type.(type) {\n\t\tcase *pb.DeliverResponse_FilteredBlock:\n\t\t\tfilteredTransactions := r.FilteredBlock.FilteredTransactions\n\t\t\tfor _, tx := range filteredTransactions {\n\t\t\t\tif tx.Txid == dg.TxID {\n\t\t\t\t\tlogger.Infof(\"txid [%s] committed with status (%s) at %s\", dg.TxID, tx.TxValidationCode, dc.Address)\n\t\t\t\t\tif tx.TxValidationCode != pb.TxValidationCode_VALID {\n\t\t\t\t\t\terr = errors.Errorf(\"transaction invalidated with status (%s)\", tx.TxValidationCode)\n\t\t\t\t\t\tdg.setError(err)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\tcase *pb.DeliverResponse_Status:\n\t\t\terr = errors.Errorf(\"deliver completed with status (%s) before txid received\", r.Status)\n\t\t\tdg.setError(err)\n\t\t\treturn\n\t\tdefault:\n\t\t\terr = errors.Errorf(\"received unexpected response type (%T) from %s\", r, dc.Address)\n\t\t\tdg.setError(err)\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// WaitForWG waits for the deliverGroup's wait group and closes","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/chaincode/common.go#L721-L757","documentation":"When the deliver service reports the transaction's validation code in a filtered block, any code other than VALID means the transaction was rejected by the committer. ClientWait surfaces the specific validation status in this error.","triggerScenarios":"An invoke whose endorsement was accepted and broadcast, but failed validation at commit — e.g. MVCC_READ_CONFLICT (concurrent writes to same key), endorsement policy failure, invalid chaincode status, or duplicate txid.","commonSituations":"High-contention workloads causing MVCC conflicts; submitting the same txid twice; chaincode returning an error that still produced an endorsed tx; endorsement policy not satisfied.","solutions":["Read the status in the message (e.g. MVCC_READ_CONFLICT) and address the root cause — retry with fresh reads for MVCC conflicts","Ensure unique txids (never reuse generated proposal IDs)","Verify chaincode logic returns success and satisfies the endorsement policy before invoking","Check peer logs for the exact validation failure details for the txid"],"exampleFix":"// before\nresp, _ := contract.SubmitTransaction(\"put\", key, value) // key hotly contended by many clients\n// after\n// retry with backoff on MVCC conflicts\nfor i := 0; i < 3; i++ {\n    resp, err := contract.SubmitTransaction(\"put\", key, value)\n    if err == nil || !strings.Contains(fmt.Sprint(err), \"MVCC_READ_CONFLICT\") { break }\n    time.Sleep(time.Duration(1<<i) * 100 * time.Millisecond)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"transaction invalidated with status\") {\n    status := extractBetween(err.Error(), \"status (\", \")\")\n    switch status {\n    case \"MVCC_READ_CONFLICT\":\n        return retryWithBackoff(invoke)\n    default:\n        return fmt.Errorf(\"tx rejected: %s — check endorsement policy and chaincode logs\", status)\n    }\n}","preventionTips":["Design keys/workloads to minimize concurrent writes to the same key","Always generate fresh txids","Validate chaincode logic and endorsement policies before deploying"],"tags":["fabric","commit","mvcc","validation"],"backgroundTag":"transaction-validation-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"}