{"record":{"id":"8423d465b20122b4","repo":"hyperledger/fabric","slug":"unable-to-check-whether-collection-existed-earlier","errorCode":null,"errorMessage":"unable to check whether collection existed earlier for chaincode %s:%s","messagePattern":"unable to check whether collection existed earlier for chaincode (.+?):(.+?)","errorType":"exception","errorClass":"VSCCExecutionFailureError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":421,"sourceCode":"\tif err != nil {\n\t\treturn &commonerrors.VSCCExecutionFailureError{Err: fmt.Errorf(\"failed obtaining query executor: %v\", err)}\n\t}\n\tdefer channelState.Done()\n\n\tstate := &state{channelState}\n\n\t// The following condition check added in v1.1 may not be needed as it is not possible to have the chaincodeName~collection key in\n\t// the lscc namespace before a chaincode deploy. To avoid forks in v1.2, the following condition is retained.\n\tif lsccFunc == lscc.DEPLOY {\n\t\tcolCriteria := privdata.CollectionCriteria{Channel: channelName, Namespace: cdRWSet.Name}\n\t\tccp, err := privdata.RetrieveCollectionConfigPackageFromState(colCriteria, state)\n\t\tif err != nil {\n\t\t\t// fail if we get any error other than NoSuchCollectionError\n\t\t\t// because it means something went wrong while looking up the\n\t\t\t// older collection\n\t\t\tif _, ok := err.(privdata.NoSuchCollectionError); !ok {\n\t\t\t\treturn &commonerrors.VSCCExecutionFailureError{\n\t\t\t\t\tErr: fmt.Errorf(\"unable to check whether collection existed earlier for chaincode %s:%s\",\n\t\t\t\t\t\tcdRWSet.Name, cdRWSet.Version),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ccp != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"collection data should not exist for chaincode %s:%s\", cdRWSet.Name, cdRWSet.Version))\n\t\t}\n\t}\n\n\t// TODO: Once the new chaincode lifecycle is available (FAB-8724), the following validation\n\t// and other validation performed in ValidateLSCCInvocation can be moved to LSCC itself.\n\tnewCollectionConfigPackage := &pb.CollectionConfigPackage{}\n\n\tif collectionsConfigArg != nil {\n\t\terr := proto.Unmarshal(collectionsConfigArg, newCollectionConfigPackage)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"invalid collection configuration supplied for chaincode %s:%s\",\n\t\t\t\tcdRWSet.Name, cdRWSet.Version))","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L403-L439","documentation":"When deploying a chaincode with collections, VSCC checks whether the collection already existed earlier via the state's CheckCollectionIsPresentInPreviousExpFile. Any error other than privdata.NoSuchCollectionError is wrapped in a VSCCExecutionFailureError with this message, meaning the lookup of the older collection configuration itself failed (as opposed to the collection simply existing).","triggerScenarios":"CheckCollectionIsPresentInPreviousExpFile returns a non-NoSuchCollectionError while validating an lscc deploy — e.g. corrupted or inaccessible experimental/collections state data in the ledger, an internal store error reading the '~collection' keys, or a query executor problem during the previous-config lookup.","commonSituations":"Ledger state corrupted after a crash or failed migration; custom/experimental collection persistence data damaged; database-level failures (CouchDB errors, bad state keys) surfacing during validation of an upgrade transaction.","solutions":["Inspect peer logs for the underlying store error from CheckCollectionIsPresentInPreviousExpFile and fix the state database.","Verify ledger integrity; if state data is corrupted, restore the peer from a known-good snapshot or resync from genesis/orderer.","Retry the transaction after the state store is healthy — VSCCExecutionFailureError is treated as transient, not a policy rejection.","Ensure consistent Fabric versions between peers so collection state lookups use the same key schema."],"exampleFix":"// before: corrupted state leads to lookup failure\npeer node start  # validation fails with VSCCExecutionFailureError\n// after: restore state store and restart\npeer node stop && rm -rf /var/hyperledger/production/ledgersData/stateLeveldb && peer node start  # resync from orderer","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Distinguish transient lookup failures from NoSuchCollectionError in custom validators\nif err := checkCollectionIsPresentInPreviousExpFile(...); err != nil {\n  if _, ok := err.(privdata.NoSuchCollectionError); !ok {\n    // wrap as VSCCExecutionFailureError — transient, may be retried\n    return &commonerrors.VSCCExecutionFailureError{Err: fmt.Errorf(\"unable to check whether collection existed earlier: %v\", err)}\n  }\n}","preventionTips":["Keep ledger state stores healthy; corruption in state data triggers this lookup failure","Restore peers from known-good snapshots after crashes instead of running with partially-written state","Keep peer Fabric versions uniform so previous-collection lookups use the same key schema","Monitor for repeated VSCCExecutionFailureError which signals persistent store problems"],"tags":["fabric","vscc","collections","ledger","execution-failure"],"backgroundTag":"collection-state-lookup-failed","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"}