{"record":{"id":"05eaa330e60dfedc","repo":"hyperledger/fabric","slug":"invalid-chaincode-version-s","errorCode":null,"errorMessage":"invalid chaincode version '%s'","messagePattern":"invalid chaincode version '(.+?)'","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":558,"sourceCode":"\t\t\treturn policyErr(fmt.Errorf(\"unexpected chaincode spec type: %s\", cdsArgs.ChaincodeSpec.Type.String()))\n\t\t}\n\n\t\t// validate chaincode name\n\t\tccName := cdsArgs.ChaincodeSpec.ChaincodeId.Name\n\t\t// it must comply with the lscc.ChaincodeNameRegExp\n\t\tif !lscc.ChaincodeNameRegExp.MatchString(ccName) {\n\t\t\treturn policyErr(errors.Errorf(\"invalid chaincode name '%s'\", ccName))\n\t\t}\n\t\t// it can't match the name of one of the system chaincodes\n\t\tif _, in := systemChaincodeNames[ccName]; in {\n\t\t\treturn policyErr(errors.Errorf(\"chaincode name '%s' is reserved for system chaincodes\", ccName))\n\t\t}\n\n\t\t// validate chaincode version\n\t\tccVersion := cdsArgs.ChaincodeSpec.ChaincodeId.Version\n\t\t// it must comply with the lscc.ChaincodeVersionRegExp\n\t\tif !lscc.ChaincodeVersionRegExp.MatchString(ccVersion) {\n\t\t\treturn policyErr(errors.Errorf(\"invalid chaincode version '%s'\", ccVersion))\n\t\t}\n\n\t\t// get the rwset\n\t\tpRespPayload, err := protoutil.UnmarshalProposalResponsePayload(cap.Action.ProposalResponsePayload)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"GetProposalResponsePayload error %s\", err))\n\t\t}\n\t\tif pRespPayload.Extension == nil {\n\t\t\treturn policyErr(fmt.Errorf(\"nil pRespPayload.Extension\"))\n\t\t}\n\t\trespPayload, err := protoutil.UnmarshalChaincodeAction(pRespPayload.Extension)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"GetChaincodeAction error %s\", err))\n\t\t}\n\t\ttxRWSet := &rwsetutil.TxRwSet{}\n\t\tif err = txRWSet.FromProtoBytes(respPayload.Results); err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"txRWSet.FromProtoBytes error %s\", err))\n\t\t}","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L540-L576","documentation":"The chaincode version in the deployment spec must match lscc.ChaincodeVersionRegExp. A version string with disallowed characters in a deploy/upgrade transaction causes VSCC to reject it with this policy error.","triggerScenarios":"Deploying/upgrading with ChaincodeId.Version containing characters outside the allowed set (alphanumeric, '-', '.', '+', '~' patterns), e.g. spaces, underscores, or tags like \"v 1.0 beta\".","commonSituations":"Passing a git tag or branch name with slashes/spaces as the -v flag, build scripts injecting un sanitized versions, or using semver build metadata unsupported by the peer's regex.","solutions":["Use a version string matching ChaincodeVersionRegExp, e.g. \"1.0\", \"1.0.1\", \"1.0-beta\".","Sanitize version strings in CI/deploy scripts before passing -v to `peer chaincode deploy`.","Re-run the upgrade with a corrected version if a bad version slipped into the channel."],"exampleFix":"// before\nversion := \"v1.0 (beta)\"\n// after\nversion := \"1.0-beta\"","handlingStrategy":"validation","validationCode":"var chaincodeVersionRegexp = regexp.MustCompile(\"^[A-Za-z0-9_.+-]+$\")\nif !chaincodeVersionRegexp.MatchString(ccVersion) {\n    return fmt.Errorf(\"version %q will be rejected by VSCC\", ccVersion)\n}","typeGuard":"func isValidChaincodeVersion(v string) bool {\n    return regexp.MustCompile(\"^[A-Za-z0-9_.+-]+$\").MatchString(v)\n}","tryCatchPattern":"if !isValidChaincodeVersion(version) {\n    return fmt.Errorf(\"refusing to deploy: invalid chaincode version %q\", version)\n}","preventionTips":["Sanitize CI-provided version strings (git tags/branches) before -v.","Use plain semver strings like 1.0.0 for chaincode versions.","Validate in deploy tooling before invoking lscc."],"tags":["fabric","vscc","lscc","chaincode-version","regex-validation"],"backgroundTag":"invalid-chaincode-version","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"}