{"record":{"id":"fd24f12e6a02106d","repo":"hyperledger/fabric","slug":"chaincode-definition-not-agreed-to-by-this-org-s","errorCode":null,"errorMessage":"chaincode definition not agreed to by this org (%s)","messagePattern":"chaincode definition not agreed to by this org \\((.+?)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/scc.go","lineNumber":623,"sourceCode":"\tlogger.Debugf(\n\t\t\"received invocation of CommitChaincodeDefinition on channel '%s' for definition '%s'\",\n\t\ti.Stub.GetChannelID(),\n\t\tcd,\n\t)\n\n\tapprovals, err := i.SCC.Functions.CommitChaincodeDefinition(\n\t\ti.Stub.GetChannelID(),\n\t\tinput.Name,\n\t\tcd,\n\t\ti.Stub,\n\t\topaqueStates,\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !approvals[myOrg] {\n\t\treturn nil, errors.Errorf(\"chaincode definition not agreed to by this org (%s)\", i.SCC.OrgMSPID)\n\t}\n\n\tlogger.Infof(\"Successfully endorsed commit for chaincode name '%s' on channel '%s' with definition {%s}\", input.Name, i.Stub.GetChannelID(), cd)\n\n\treturn &lb.CommitChaincodeDefinitionResult{}, nil\n}\n\n// QueryChaincodeDefinition is a SCC function that may be dispatched\n// to which routes to the underlying lifecycle implementation.\nfunc (i *Invocation) QueryChaincodeDefinition(input *lb.QueryChaincodeDefinitionArgs) (proto.Message, error) {\n\tlogger.Debugf(\n\t\t\"received invocation of QueryChaincodeDefinition on channel '%s' for chaincode '%s'\",\n\t\ti.Stub.GetChannelID(),\n\t\tinput.Name,\n\t)\n\n\tdefinedChaincode, err := i.SCC.Functions.QueryChaincodeDefinition(input.Name, i.Stub)\n\tif err != nil {","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/scc.go#L605-L641","documentation":"CommitChaincodeDefinition evaluates the chaincode definition's approval state; each org must have approved (ApprovedChaincodeDefinitionForMyOrg) before commit. If this peer's org has no recorded approval matching the submitted definition (sequence, version, endorsement policy, collections), the commit endorsement fails with this message naming the org.","triggerScenarios":"Calling CommitChaincodeDefinition when the org has not run ApproveChaincodeDefinitionForMyOrg for the same chaincode name/sequence, or approved a definition whose fields (version, sequence, endorsement policy, collection config, init-required) differ from the committed one.","commonSituations":"Skipping the approve step for one org, approving with a mismatched sequence number after an upgrade, differing package IDs across orgs' approve calls, or approving on a different channel.","solutions":["Run ApproveChaincodeDefinitionForMyOrg with the exact same sequence, version, package ID, endorsement policy and collections as the definition being committed","Check approval status with QueryApprovedChaincodeDefinition (checkcommitreadiness) to see which orgs are missing approvals","Increment the sequence number and have all orgs re-approve if the definition has changed"],"exampleFix":"// before\npeer lifecycle chaincode commit -C mychannel   # no approval recorded for this org\n// after\npeer lifecycle chaincode approveformyorg -C mychannel --packageID $CC_PACKAGE_ID --sequence 1\npeer lifecycle chaincode commit -C mychannel","handlingStrategy":"validation","validationCode":"// shell: gate commit on readiness output containing all required orgs\npeer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1.0 --sequence 1 --output json\n# require \"Org1MSP\": true, \"Org2MSP\": true before commit","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not agreed to by this org\") {\n    // prompt operator to run approveformyorg with identical definition\n}","preventionTips":["Always run approveformyorg on each org's peer before commit","Use checkcommitreadiness to confirm all orgs approved","Keep sequence/version/endorsement-policy/collections identical across org approvals"],"tags":["hyperledger-fabric","chaincode-lifecycle","approval"],"backgroundTag":"chaincode-definition-not-approved","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"}