hyperledger/fabric · error

the proposed collection config does not contain previously d

Error message

the proposed collection config does not contain previously defined collections

What it means

When a chaincode already has committed collections, any upgrade must re-include every existing collection. This error is thrown when the committed definition has collection data but the proposed definition supplies none, because fabric would interpret the missing entries as dropping existing collections, which is forbidden.

Source

Thrown at core/chaincode/lifecycle/scc.go:929

	for _, rule := range sp.GetNOutOf().Rules {
		err := validateSpOrConcat(rule)
		if err != nil {
			return err
		}
	}
	return nil
}

func validateCollConfigsAgainstCommittedDef(
	proposedCollConfs []*pb.StaticCollectionConfig,
	committedCollConfPkg *pb.CollectionConfigPackage,
) error {
	if committedCollConfPkg == nil || len(committedCollConfPkg.Config) == 0 {
		return nil
	}

	if len(proposedCollConfs) == 0 {
		return errors.Errorf("the proposed collection config does not contain previously defined collections")
	}

	proposedCollsMap := map[string]*pb.StaticCollectionConfig{}
	for _, c := range proposedCollConfs {
		proposedCollsMap[c.Name] = c
	}

	// In the new collection config package, ensure that there is one entry per old collection. Any
	// number of new collections are allowed.
	for _, committedCollConfig := range committedCollConfPkg.Config {
		committedColl := committedCollConfig.GetStaticCollectionConfig()
		// It cannot be nil
		if committedColl == nil {
			return errors.Errorf("unknown collection configuration type")
		}

		newCollection, ok := proposedCollsMap[committedColl.Name]
		if !ok {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Pass the full collection config (including all previously defined collections) on the upgrade via --collections-config.
  2. Read the committed definition's collection config (via QueryApprovedChaincodeDefinition or committed data) and include it in the new definition.
  3. Do not omit the collections-config flag once collections exist for the chaincode.

Example fix

// before: upgrade without collections
peer chaincode invoke -C mychannel -n _lifecycle -c '{"Args":["ApproveChaincodeDefinitionForMyOrg",...,"{}"]}'
// after: include existing + new collections
peer chaincode invoke ... -c '{"Args":["ApproveChaincodeDefinitionForMyOrg",...,"{\"collection1\":{...}}"]}'
Defensive patterns

Strategy: validation

Validate before calling

committed, _ := qc.QueryChaincodeDefinitionResult(ccName, channelID)
if committed.Collections != nil && len(proposedCollections) == 0 {
  return fmt.Errorf("chaincode %s has committed collections; upgrade must include them", ccName)
}

Type guard

func hasCommittedCollections(def *lifecycle.QueryChaincodeDefinitionResult) bool {
  return def != nil && def.Collections != nil && len(def.Collections.Config) > 0
}

Try / catch

if err := commit(...); err != nil {
  if strings.Contains(err.Error(), "does not contain previously defined collections") {
    // re-run with full --collections-config including existing collections
  }
  return err
}

Prevention

When it happens

Trigger: Upgrading a chaincode definition (approveformyorg / commit / _lifecycle chaincode) that previously had collections configured, but omitting --collections-config or passing an empty collection config.

Common situations: Upgrade performed with CLI that omits the collections-config flag used in the original deployment; tooling that rebuilds definitions from scratch and forgets prior collection packages.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/5d6b9f62ea108d7d. Report an issue: GitHub.