{"record":{"id":"1f48740d4ebdebba","repo":"hyperledger/fabric","slug":"requested-sequence-is-d-but-new-definition-must","errorCode":null,"errorMessage":"requested sequence is %d, but new definition must be sequence %d","messagePattern":"requested sequence is (.+?), but new definition must be sequence (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/lifecycle.go","lineNumber":332,"sourceCode":"\tBuildRegistry             *container.BuildRegistry\n\tmutex                     sync.Mutex\n\tBuildLocks                map[string]*sync.Mutex\n\tconcurrentInstalls        uint32\n}\n\n// CheckCommitReadiness takes a chaincode definition, checks that\n// its sequence number is the next allowable sequence number and checks which\n// organizations have approved the definition.\nfunc (ef *ExternalFunctions) CheckCommitReadiness(chname, ccname string, cd *ChaincodeDefinition, publicState ReadWritableState, orgStates []OpaqueState) (approvals map[string]bool, mismatches map[string][]string, err error) {\n\tvar currentSequence int64\n\tcurrentSequence, err = ef.Resources.Serializer.DeserializeFieldAsInt64(NamespacesName, ccname, \"Sequence\", publicState)\n\tif err != nil {\n\t\terr = errors.WithMessage(err, \"could not get current sequence\")\n\t\treturn\n\t}\n\n\tif cd.Sequence != currentSequence+1 {\n\t\terr = errors.Errorf(\"requested sequence is %d, but new definition must be sequence %d\", cd.Sequence, currentSequence+1)\n\t\treturn\n\t}\n\n\tif err = ef.SetChaincodeDefinitionDefaults(chname, cd); err != nil {\n\t\terr = errors.WithMessagef(err, \"could not set defaults for chaincode definition in channel %s\", chname)\n\t\treturn\n\t}\n\n\tif approvals, mismatches, err = ef.QueryOrgApprovals(ccname, cd, orgStates); err != nil {\n\t\treturn\n\t}\n\n\tlogger.Infof(\"Successfully checked commit readiness of chaincode name '%s' on channel '%s' with definition {%s}\", ccname, chname, cd)\n\n\treturn\n}\n\n// CommitChaincodeDefinition takes a chaincode definition, checks that its","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/lifecycle.go#L314-L350","documentation":"Thrown by CheckCommitReadiness when the sequence number in the proposed ChaincodeDefinition does not equal the currently committed sequence plus one. Lifecycle requires definitions to be committed strictly sequentially; gaps or repeats are rejected.","triggerScenarios":"Committing/approving a definition with cd.Sequence lower or higher than currentSequence+1 — e.g. re-committing the same sequence after it is already committed, or skipping a sequence number.","commonSituations":"Re-running the same approve/commit command twice; multiple operators incrementing sequences independently causing a gap; stale knowledge of the current committed sequence after other orgs committed an update.","solutions":["Query the current committed sequence ('peer lifecycle chaincode querycommitted') and set sequence to current+1","If the definition is unchanged and already committed, no action is needed — the commit is redundant","Increment the sequence exactly once for each new definition change and re-approve on all orgs"],"exampleFix":"// before\napproveformyorg --sequence 1 // committed sequence is already 1\n// after\napproveformyorg --sequence 2 // current sequence 1 + 1","handlingStrategy":"validation","validationCode":"committed, err := lifecycleQueryCommitted(chname, ccname, publicState)\nif err != nil { committedSeq = 0 } else { committedSeq = committed.Sequence }\nif cd.Sequence != committedSeq+1 {\n    return fmt.Errorf(\"set --sequence to %d (current committed sequence is %d)\", committedSeq+1, committedSeq)\n}","typeGuard":"func nextSequence(committedSeq uint64) uint64 { return committedSeq + 1 }","tryCatchPattern":"if err := lifecycle.CheckCommitReadiness(chname, cd, ...); err != nil {\n    if strings.Contains(err.Error(), \"requested sequence is\") {\n        // re-query committed sequence and resubmit with current+1\n    }\n    return err\n}","preventionTips":["Always query the committed sequence immediately before approving/committing","Increment the sequence by exactly one per definition change — never reuse or skip numbers","Coordinate sequence increments across organizations to avoid concurrent conflicting approvals"],"tags":["hyperledger-fabric","lifecycle","sequence-number","commit-readiness"],"backgroundTag":"chaincode-sequence-mismatch","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"}