hyperledger/fabric · error
chaincode definition not agreed to by this org (%s)
Error message
chaincode definition not agreed to by this org (%s)
What it means
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.
Source
Thrown at core/chaincode/lifecycle/scc.go:623
logger.Debugf(
"received invocation of CommitChaincodeDefinition on channel '%s' for definition '%s'",
i.Stub.GetChannelID(),
cd,
)
approvals, err := i.SCC.Functions.CommitChaincodeDefinition(
i.Stub.GetChannelID(),
input.Name,
cd,
i.Stub,
opaqueStates,
)
if err != nil {
return nil, err
}
if !approvals[myOrg] {
return nil, errors.Errorf("chaincode definition not agreed to by this org (%s)", i.SCC.OrgMSPID)
}
logger.Infof("Successfully endorsed commit for chaincode name '%s' on channel '%s' with definition {%s}", input.Name, i.Stub.GetChannelID(), cd)
return &lb.CommitChaincodeDefinitionResult{}, nil
}
// QueryChaincodeDefinition is a SCC function that may be dispatched
// to which routes to the underlying lifecycle implementation.
func (i *Invocation) QueryChaincodeDefinition(input *lb.QueryChaincodeDefinitionArgs) (proto.Message, error) {
logger.Debugf(
"received invocation of QueryChaincodeDefinition on channel '%s' for chaincode '%s'",
i.Stub.GetChannelID(),
input.Name,
)
definedChaincode, err := i.SCC.Functions.QueryChaincodeDefinition(input.Name, i.Stub)
if err != nil {View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before peer lifecycle chaincode commit -C mychannel # no approval recorded for this org // after peer lifecycle chaincode approveformyorg -C mychannel --packageID $CC_PACKAGE_ID --sequence 1 peer lifecycle chaincode commit -C mychannel
Defensive patterns
Strategy: validation
Validate before calling
// shell: gate commit on readiness output containing all required orgs peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1.0 --sequence 1 --output json # require "Org1MSP": true, "Org2MSP": true before commit
Try / catch
if err != nil && strings.Contains(err.Error(), "not agreed to by this org") {
// prompt operator to run approveformyorg with identical definition
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- chaincode definition for '%s' at sequence %d on channel '%s'
- could not get channel config for channel '%s'
- could not get application config for channel '%s'
- no such collection '%s'
- chaincode cache at sequence %d but current sequence is %d, c
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/fd24f12e6a02106d.
Report an issue: GitHub.