{"record":{"id":"048a9263af6d11cb","repo":"hyperledger/fabric","slug":"invalid-chaincode-name-s","errorCode":null,"errorMessage":"invalid chaincode name '%s'","messagePattern":"invalid chaincode name '(.+?)'","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":547,"sourceCode":"\t\t\treturn policyErr(fmt.Errorf(\"GetChaincodeDeploymentSpec error %s\", err))\n\t\t}\n\n\t\tif cdsArgs == nil || cdsArgs.ChaincodeSpec == nil || cdsArgs.ChaincodeSpec.ChaincodeId == nil ||\n\t\t\tcap.Action == nil || cap.Action.ProposalResponsePayload == nil {\n\t\t\treturn policyErr(fmt.Errorf(\"VSCC error: invocation of lscc(%s) does not have appropriate arguments\", lsccFunc))\n\t\t}\n\n\t\tswitch cdsArgs.ChaincodeSpec.Type.String() {\n\t\tcase \"GOLANG\", \"NODE\", \"JAVA\", \"CAR\":\n\t\tdefault:\n\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}","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L529-L565","documentation":"The chaincode name in the deployment spec must match lscc.ChaincodeNameRegExp. VSCC rejects deploy/upgrade transactions whose ChaincodeId.Name contains characters outside the allowed set, marking the transaction invalid via a policy error.","triggerScenarios":"Deploying or upgrading a chaincode whose name contains characters like spaces, slashes, or symbols not permitted by ChaincodeNameRegExp (allowed: alphanumeric plus a few safe characters such as dash and underscore).","commonSituations":"Typo or shell interpolation adding spaces into the -n flag of `peer chaincode deploy`, names generated from untrusted input, or names with path separators/version suffixes accidentally included.","solutions":["Rename the chaincode to conform to ChaincodeNameRegExp (letters, digits, '-' and '_' only) and redeploy.","Trim/sanitize the name argument in your deploy scripts before invoking lscc.","Check CLI/SDK flags for accidental quoting or whitespace in the chaincode name parameter."],"exampleFix":"// before\nname := \"my chaincode/v1\"\n// after\nname := \"my-chaincode_v1\" // matches lscc.ChaincodeNameRegExp","handlingStrategy":"validation","validationCode":"var chaincodeNameRegexp = regexp.MustCompile(\"^[a-zA-Z0-9_-]+$\")\nif !chaincodeNameRegexp.MatchString(ccName) {\n    return fmt.Errorf(\"name %q will be rejected by VSCC\", ccName)\n}","typeGuard":"func isValidChaincodeName(name string) bool {\n    return regexp.MustCompile(\"^[a-zA-Z0-9_-]+$\").MatchString(name)\n}","tryCatchPattern":"if !isValidChaincodeName(name) {\n    return fmt.Errorf(\"refusing to deploy: invalid chaincode name %q\", name)\n}","preventionTips":["Mirror lscc.ChaincodeNameRegExp in deploy tooling before submission.","Quote/trim shell variables used for the -n flag.","Disallow names derived from unsanitized user input."],"tags":["fabric","vscc","lscc","chaincode-name","regex-validation"],"backgroundTag":"invalid-chaincode-name","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"}