hyperledger/fabric · error

chaincode type not supported: %s

Error message

chaincode type not supported: %s

What it means

ApplyDatabaseSecurity() builds the security URL by parsing the CouchDB instance URL with url.Parse. If the configured connection URL is malformed (e.g. missing scheme, illegal characters, whitespace), url.Parse fails and the error is wrapped as 'error parsing CouchDB URL: <url>'. The security update is not applied.

Source

Thrown at ccaas_builder/cmd/detect/main.go:63

	metadataFile := filepath.Join(chaincodeMetaData, "metadata.json")
	if _, err := os.Stat(metadataFile); err != nil {
		return errors.WithMessagef(err, "%s not found ", metadataFile)
	}

	// Read the metadata file
	mdbytes, err := os.ReadFile(metadataFile)
	if err != nil {
		return errors.WithMessagef(err, "%s not readable", metadataFile)
	}

	var metadata chaincodeMetadata
	err = json.Unmarshal(mdbytes, &metadata)
	if err != nil {
		return errors.WithMessage(err, "Unable to parse the metadata.json file")
	}

	if strings.ToLower(metadata.Type) != "ccaas" {
		return fmt.Errorf("chaincode type not supported: %s", metadata.Type)
	}

	// returning nil indicates to the peer a successful detection
	return nil
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Fix ledger.state.couchDBConfig.couchDBAddress in the peer's core.yaml (must be host:port, e.g. couchdb:5984)
  2. Check the CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS env override resolves to a real value
  3. Ensure any IPv6 address is bracketed, e.g. [::1]:5984
  4. Log/inspect dbclient.couchInstance.url() and validate it with url.Parse before use
  5. If constructing programmatically, use url.URL fields or net.JoinHostPort instead of string concatenation

Example fix

// before (core.yaml)
couchDBAddress: $COUCHDB_HOST:5984   # unset env -> literal '$COUCHDB_HOST:5984'
// after
couchDBAddress: couchdb:5984
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(couchAddress) // couchAddress from core.yaml
if err != nil || u.Host == "" {
    return fmt.Errorf("invalid couchDBAddress %q: %v", couchAddress, err)
}

Try / catch

err := db.ApplyDatabaseSecurity(sec)
if err != nil && strings.Contains(err.Error(), "error parsing CouchDB URL") {
    // surface the configured address for operators to fix
    return fmt.Errorf("check ledger.state.couchDBConfig.couchDBAddress: %w", err)
}

Prevention

When it happens

Trigger: Calling ApplyDatabaseSecurity() when couchInstance.url() returns a malformed URL — typically a bad CouchAddress in core.yaml (ledger.state.couchDBConfig.couchDBAddress), a bad address passed to CreateCouchInstance, or one containing spaces/control characters.

Common situations: Typo in couchDBAddress (e.g. 'couchdb:5984 ' with trailing space, or missing host), env var substitution leaving placeholders like 'COUCHDB_HOST:5984' unresolved, IPv6 literal without brackets, or misconfigured peer core.yaml after a migration.

Related errors


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