hyperledger/fabric · error · VSCCEndorsementPolicyError
invalid chaincode name '%s'
Error message
invalid chaincode name '%s'
What it means
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.
Source
Thrown at core/handlers/validation/builtin/v12/validation_logic.go:547
return policyErr(fmt.Errorf("GetChaincodeDeploymentSpec error %s", err))
}
if cdsArgs == nil || cdsArgs.ChaincodeSpec == nil || cdsArgs.ChaincodeSpec.ChaincodeId == nil ||
cap.Action == nil || cap.Action.ProposalResponsePayload == nil {
return policyErr(fmt.Errorf("VSCC error: invocation of lscc(%s) does not have appropriate arguments", lsccFunc))
}
switch cdsArgs.ChaincodeSpec.Type.String() {
case "GOLANG", "NODE", "JAVA", "CAR":
default:
return policyErr(fmt.Errorf("unexpected chaincode spec type: %s", cdsArgs.ChaincodeSpec.Type.String()))
}
// validate chaincode name
ccName := cdsArgs.ChaincodeSpec.ChaincodeId.Name
// it must comply with the lscc.ChaincodeNameRegExp
if !lscc.ChaincodeNameRegExp.MatchString(ccName) {
return policyErr(errors.Errorf("invalid chaincode name '%s'", ccName))
}
// it can't match the name of one of the system chaincodes
if _, in := systemChaincodeNames[ccName]; in {
return policyErr(errors.Errorf("chaincode name '%s' is reserved for system chaincodes", ccName))
}
// validate chaincode version
ccVersion := cdsArgs.ChaincodeSpec.ChaincodeId.Version
// it must comply with the lscc.ChaincodeVersionRegExp
if !lscc.ChaincodeVersionRegExp.MatchString(ccVersion) {
return policyErr(errors.Errorf("invalid chaincode version '%s'", ccVersion))
}
// get the rwset
pRespPayload, err := protoutil.UnmarshalProposalResponsePayload(cap.Action.ProposalResponsePayload)
if err != nil {
return policyErr(fmt.Errorf("GetProposalResponsePayload error %s", err))
}View on GitHub (pinned to 2736b63f8f)
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.
Example fix
// before name := "my chaincode/v1" // after name := "my-chaincode_v1" // matches lscc.ChaincodeNameRegExp
Defensive patterns
Strategy: validation
Validate before calling
var chaincodeNameRegexp = regexp.MustCompile("^[a-zA-Z0-9_-]+$")
if !chaincodeNameRegexp.MatchString(ccName) {
return fmt.Errorf("name %q will be rejected by VSCC", ccName)
} Type guard
func isValidChaincodeName(name string) bool {
return regexp.MustCompile("^[a-zA-Z0-9_-]+$").MatchString(name)
} Try / catch
if !isValidChaincodeName(name) {
return fmt.Errorf("refusing to deploy: invalid chaincode name %q", name)
} Prevention
- Mirror lscc.ChaincodeNameRegExp in deploy tooling before submission.
- Quote/trim shell variables used for the -n flag.
- Disallow names derived from unsanitized user input.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- invalid chaincode version '%s'
- invalid key for the collection of chaincode %s:%s; expected
- collection configuration arguments supplied for chaincode %s
- GetChaincodeDeploymentSpec error %s
- VSCC error: invocation of lscc(%s) does not have appropriate
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/048a9263af6d11cb.
Report an issue: GitHub.