{"record":{"id":"8571ed16bc0f7fc3","repo":"hyperledger/fabric","slug":"currently-defined-sequence-d-is-larger-than-reque","errorCode":null,"errorMessage":"currently defined sequence %d is larger than requested sequence %d","messagePattern":"currently defined sequence (.+?) is larger than requested sequence (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/lifecycle.go","lineNumber":435,"sourceCode":"\n// ApproveChaincodeDefinitionForOrg adds a chaincode definition entry into the passed in Org state.  The definition must be\n// for either the currently defined sequence number or the next sequence number.  If the definition is\n// for the current sequence number, then it must match exactly the current definition or it will be rejected.\nfunc (ef *ExternalFunctions) ApproveChaincodeDefinitionForOrg(chname, ccname string, cd *ChaincodeDefinition, packageID string, publicState ReadableState, orgState ReadWritableState) error {\n\t// Get the current sequence from the public state\n\tcurrentSequence, err := ef.Resources.Serializer.DeserializeFieldAsInt64(NamespacesName, ccname, \"Sequence\", publicState)\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"could not get current sequence\")\n\t}\n\n\trequestedSequence := cd.Sequence\n\n\tif currentSequence == requestedSequence && requestedSequence == 0 {\n\t\treturn errors.Errorf(\"requested sequence is 0, but first definable sequence number is 1\")\n\t}\n\n\tif requestedSequence < currentSequence {\n\t\treturn errors.Errorf(\"currently defined sequence %d is larger than requested sequence %d\", currentSequence, requestedSequence)\n\t}\n\n\tif requestedSequence > currentSequence+1 {\n\t\treturn errors.Errorf(\"requested sequence %d is larger than the next available sequence number %d\", requestedSequence, currentSequence+1)\n\t}\n\n\tif err := ef.SetChaincodeDefinitionDefaults(chname, cd); err != nil {\n\t\treturn errors.WithMessagef(err, \"could not set defaults for chaincode definition in channel %s\", chname)\n\t}\n\n\tprivateName := fmt.Sprintf(\"%s#%d\", ccname, requestedSequence)\n\n\tif requestedSequence == currentSequence {\n\t\tmetadata, ok, err := ef.Resources.Serializer.DeserializeMetadata(NamespacesName, ccname, publicState)\n\t\tif err != nil {\n\t\t\treturn errors.WithMessage(err, \"could not fetch metadata for current definition\")\n\t\t}\n\t\tif !ok {","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/lifecycle.go#L417-L453","documentation":"ApproveChaincodeDefinitionForOrg guard: the org's approval request names a sequence number that is lower than the sequence already committed in public state, so approving it would move the definition backwards.","triggerScenarios":"Approving a definition whose Sequence field is less than the current committed sequence — e.g., re-running an old approve command with --sequence 1 after sequence 2 is already committed, or deploying a chaincode package built from a stale definition.","commonSituations":"Replaying old scripts after an upgrade; two teams using divergent sequence numbers; rebuilding a peer's org approval from an old checkout.","solutions":["Query the committed sequence ('peer lifecycle chaincode querycommitted -C mychannel') and approve with currentSequence+1","Stop replaying stale approve commands; regenerate scripts with the up-to-date sequence","If the downgrade was intentional, it is not supported — create a new definition at the next sequence instead"],"exampleFix":"// before\npeer lifecycle chaincode approveformyorg -C mychannel --sequence 1  # committed=2\n// after\npeer lifecycle chaincode approveformyorg -C mychannel --sequence 3  # current+1","handlingStrategy":"validation","validationCode":"// Compare against the committed sequence before approving\ncommitted := queryCommittedSequence(ch, ccname) // via querycommitted\nif def.Sequence < committed {\n    return fmt.Errorf(\"requested %d < committed %d; use %d\", def.Sequence, committed, committed+1)\n}","typeGuard":null,"tryCatchPattern":"err := ef.ApproveChaincodeDefinitionForOrg(...)\nif err != nil && strings.Contains(err.Error(), \"is larger than requested sequence\") {\n    // refresh sequence from querycommitted and retry with committed+1\n}","preventionTips":["Always compute the sequence as lastCommitted+1 dynamically","Avoid replaying old deployment scripts verbatim","Track upgrades centrally so teams do not diverge on sequence numbers"],"tags":["fabric","lifecycle","sequence-number"],"backgroundTag":"invalid-sequence-number","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"}