{"record":{"id":"797d31c01bc8ff4d","repo":"hyperledger/fabric","slug":"chaincode-s-has-not-been-initialized-for-this-v","errorCode":null,"errorMessage":"chaincode '%s' has not been initialized for this version, must call as init first","messagePattern":"chaincode '(.+?)' has not been initialized for this version, must call as init first","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/chaincode_support.go","lineNumber":263,"sourceCode":"\tif input.IsInit {\n\t\tif !cii.EnforceInit {\n\t\t\treturn \"\", 0, errors.Errorf(\"chaincode '%s' does not require initialization but called as init\", chaincodeName)\n\t\t}\n\n\t\tif !needsInitialization {\n\t\t\treturn \"\", 0, errors.Errorf(\"chaincode '%s' is already initialized but called as init\", chaincodeName)\n\t\t}\n\n\t\terr = txParams.TXSimulator.SetState(chaincodeName, InitializedKeyName, []byte(cii.Version))\n\t\tif err != nil {\n\t\t\treturn \"\", 0, errors.WithMessage(err, \"could not set 'initialized' key\")\n\t\t}\n\n\t\treturn cii.ChaincodeID, pb.ChaincodeMessage_INIT, nil\n\t}\n\n\tif needsInitialization {\n\t\treturn \"\", 0, errors.Errorf(\"chaincode '%s' has not been initialized for this version, must call as init first\", chaincodeName)\n\t}\n\n\treturn cii.ChaincodeID, pb.ChaincodeMessage_TRANSACTION, nil\n}\n\n// execute executes a transaction and waits for it to complete until a timeout value.\nfunc (cs *ChaincodeSupport) execute(cctyp pb.ChaincodeMessage_Type, txParams *ccprovider.TransactionParams, namespace string, input *pb.ChaincodeInput, h *Handler) (*pb.ChaincodeMessage, error) {\n\tinput.Decorations = txParams.ProposalDecorations\n\n\tpayload, err := proto.Marshal(input)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"failed to create chaincode message\")\n\t}\n\n\tccMsg := &pb.ChaincodeMessage{\n\t\tType:      cctyp,\n\t\tPayload:   payload,\n\t\tTxid:      txParams.TxID,","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/chaincode_support.go#L245-L281","documentation":"CheckInvocation guard: the chaincode requires initialization (EnforceInit) and its version's 'initialized' state key is not set, but the invocation did not use IsInit — the transaction is rejected until init runs.","triggerScenarios":"Thrown at core/chaincode/chaincode_support.go:263 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invoke the chaincode once with the init flag (--isInit) for the deployed version before normal invocations","Upgrade/redeploy the chaincode if the init-compatible version was never initialized"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}