hyperledger/fabric · error
unknown chaincodeType: %s
Error message
unknown chaincodeType: %s
What it means
Thrown by DockerVM.GetArgs when the chaincode type string (ccType) does not match any supported ChaincodeSpec type (GOLANG/CAR, JAVA, NODE). GetArgs maps the language to the container start command; an unrecognized type has no launch command, so Start fails with 'could not get args'. The error embeds the offending type string via errors.Errorf.
Source
Thrown at core/container/dockercontroller/dockercontroller.go:199
/chaincode/start.sh --peer.address %[1]s
else
cd /usr/local/src
npm start -- --peer.address %[1]s
fi
`
func (vm *DockerVM) GetArgs(ccType string, peerAddress string) ([]string, error) {
// language specific arguments, possibly should be pushed back into platforms, but were simply
// ported from the container_runtime chaincode component
switch ccType {
case pb.ChaincodeSpec_GOLANG.String(), pb.ChaincodeSpec_CAR.String():
return []string{"chaincode", fmt.Sprintf("-peer.address=%s", peerAddress)}, nil
case pb.ChaincodeSpec_JAVA.String():
return []string{"/root/chaincode-java/start", "--peerAddress", peerAddress}, nil
case pb.ChaincodeSpec_NODE.String():
return []string{"/bin/sh", "-c", fmt.Sprintf(nodeStartScript, peerAddress)}, nil
default:
return nil, errors.Errorf("unknown chaincodeType: %s", ccType)
}
}
const (
// Mutual TLS auth client key and cert paths in the chaincode container
TLSClientKeyPath string = "/etc/hyperledger/fabric/client.key"
TLSClientCertPath string = "/etc/hyperledger/fabric/client.crt"
TLSClientKeyFile string = "/etc/hyperledger/fabric/client_pem.key"
TLSClientCertFile string = "/etc/hyperledger/fabric/client_pem.crt"
TLSClientRootCertFile string = "/etc/hyperledger/fabric/peer.crt"
)
func (vm *DockerVM) GetEnv(ccid string, tlsConfig *ccintf.TLSConfig) []string {
// common environment variables
// FIXME: we are using the env variable CHAINCODE_ID to store
// the package ID; in the legacy lifecycle they used to be the
// same but now they are not, so we should use a different env
// variable. However chaincodes built by older versions of theView on GitHub (pinned to 2736b63f8f)
Solutions
- Normalize the chaincode type before calling Start (strings.ToUpper) so it matches the pb.ChaincodeSpec enum strings ('GOLANG','JAVA','NODE','CAR').
- Check where the type originated (chaincode package metadata) and repackage with a supported --lang value.
- If calling GetArgs/Start from custom code, pass pb.ChaincodeSpec_GOLANG.String() style values, not raw user input.
- Inspect the error message for the exact offending type string to confirm a casing/spelling mismatch.
Example fix
// before vm.Start(ccid, metadata.Type, peerConn) // metadata.Type = "node" // after vm.Start(ccid, strings.ToUpper(metadata.Type), peerConn) // "NODE"
Defensive patterns
Strategy: validation
Validate before calling
func validChaincodeType(t string) error {
switch strings.ToUpper(t) {
case "GOLANG", "JAVA", "NODE", "CAR":
return nil
}
return fmt.Errorf("chaincode type %q not supported; use GOLANG, JAVA, NODE or CAR", t)
}
// call before vm.Start(ccid, ccType, peerConn) Type guard
func isKnownChaincodeType(t string) bool {
switch strings.ToUpper(t) {
case pb.ChaincodeSpec_GOLANG.String(), pb.ChaincodeSpec_JAVA.String(),
pb.ChaincodeSpec_NODE.String(), pb.ChaincodeSpec_CAR.String():
return true
}
return false
} Try / catch
if err := vm.Start(ccid, ccType, peerConn); err != nil {
if strings.Contains(err.Error(), "unknown chaincodeType") {
// normalize casing / fix package metadata then retry
return vm.Start(ccid, strings.ToUpper(ccType), peerConn)
}
return err
} Prevention
- Always pass ccType through strings.ToUpper before Start/GetArgs.
- Store package metadata with canonical uppercase language names.
- Add a unit test asserting every type your deployment flow emits maps to a GetArgs case.
When it happens
Trigger: Starting a chaincode container with a ccType that is not one of GOLANG, CAR, JAVA, or NODE (case-sensitive comparison against pb.ChaincodeSpec_* strings), e.g. 'golang' lowercase, an empty string, or a custom/unknown language label from package metadata.
Common situations: Package metadata stored the type lowercase ('node' instead of 'NODE') in newer lifecycle flows; a typo in custom integration code calling Start/GetArgs directly; upgrading Fabric and deploying a chaincode type no longer supported (CAR removal).
Related errors
- Value of File: was nil
- id cannot be nil if buf is not nil
- depspec cannot be nil if buf is not nil
- nil data bytes
- platform builder failed
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/df3d38bcbc329ba4.
Report an issue: GitHub.