hyperledger/fabric · error

Unknown chaincodeType: %s

Error message

Unknown chaincodeType: %s

What it means

The platform Registry.GenerateDockerfile looks up a platform implementation by the given chaincode type string; if no platform is registered for that type, it cannot generate a Dockerfile and returns 'Unknown chaincodeType'. Only registered types (GOLANG, NODE, CAR, JAVA depending on version) are supported.

Source

Thrown at core/chaincode/platforms/platforms.go:81

func NewRegistry(platformTypes ...Platform) *Registry {
	platforms := make(map[string]Platform)
	for _, platform := range platformTypes {
		if _, ok := platforms[platform.Name()]; ok {
			logger.Panicf("Multiple platforms of the same name specified: %s", platform.Name())
		}
		platforms[platform.Name()] = platform
	}
	return &Registry{
		Platforms:     platforms,
		PackageWriter: PackageWriterWrapper(writeBytesToPackage),
		DockerBuild:   util.DockerBuild,
	}
}

func (r *Registry) GenerateDockerfile(ccType string) (string, error) {
	platform, ok := r.Platforms[ccType]
	if !ok {
		return "", fmt.Errorf("Unknown chaincodeType: %s", ccType)
	}

	var buf []string

	// ----------------------------------------------------------------------------------------------------
	// Let the platform define the base Dockerfile
	// ----------------------------------------------------------------------------------------------------
	base, err := platform.GenerateDockerfile()
	if err != nil {
		return "", fmt.Errorf("Failed to generate platform-specific Dockerfile: %s", err)
	}
	buf = append(buf, base)
	buf = append(buf, fmt.Sprintf(`LABEL %s.chaincode.type="%s" \`, metadata.BaseDockerLabel, ccType))
	buf = append(buf, fmt.Sprintf(`      %s.version="%s"`, metadata.BaseDockerLabel, metadata.Version))
	// ----------------------------------------------------------------------------------------------------
	// Then augment it with any general options
	// ----------------------------------------------------------------------------------------------------
	// append version so chaincode build version can be compared against peer build version

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Use a supported chaincode language type (e.g. GOLANG or NODE for this registry).
  2. Fix the ChaincodeSpec.Type value in the install/instantiate request.
  3. If using a custom platform, ensure it is registered in the platforms Registry before the build.
  4. Verify Fabric version supports the requested type (e.g. JAVA support depends on version).

Example fix

// before
spec.Type = pb.ChaincodeSpec_TYPE_NODE
// after
spec.Type = pb.ChaincodeSpec_NODE
Defensive patterns

Strategy: validation

Validate before calling

const supportedTypes = ['GOLANG', 'NODE', 'CAR', 'JAVA'];
if (!supportedTypes.includes(spec.Type)) {
  throw new Error(`Unsupported chaincode type: ${spec.Type}`);
}

Type guard

function isSupportedChaincodeType(type) {
  return ['GOLANG', 'NODE', 'CAR', 'JAVA'].includes(type);
}

Prevention

When it happens

Trigger: GenerateDockerBuild calling GenerateDockerfile with a ccType that is not a key of Registry.Platforms — e.g. an unsupported ChaincodeSpec_Type enum value or an empty/garbage type string.

Common situations: Submitting chaincode with a misspelled or unsupported type, using a type enabled in a different Fabric version, or custom builds where a platform plugin was not registered in the Registry.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/889c9047d19bcb7f. Report an issue: GitHub.