hyperledger/fabric · error

unknown MSP type '%s'

Error message

unknown MSP type '%s'

What it means

GetLocalMspConfigWithType builds local MSP config for a named provider type ('fabric', 'idemix'). This error means the configured mspType is not one of the known provider types, so no config builder exists for it.

Source

Thrown at msp/configbuilder.go:165

			bccspConfig.SW.FileKeystore.KeyStorePath == "" {
			bccspConfig.SW.FileKeystore = &factory.FileKeystoreOpts{KeyStorePath: keystoreDir}
		}
	}

	return bccspConfig
}

// GetLocalMspConfigWithType returns a local MSP
// configuration for the MSP in the specified
// directory, with the specified ID and type
func GetLocalMspConfigWithType(dir string, bccspConfig *factory.FactoryOpts, ID, mspType string) (*msp.MSPConfig, error) {
	switch mspType {
	case ProviderTypeToString(FABRIC):
		return GetLocalMspConfig(dir, bccspConfig, ID)
	case ProviderTypeToString(IDEMIX):
		return idemix.GetIdemixMspConfig(dir, ID)
	default:
		return nil, errors.Errorf("unknown MSP type '%s'", mspType)
	}
}

func GetLocalMspConfig(dir string, bccspConfig *factory.FactoryOpts, ID string) (*msp.MSPConfig, error) {
	signcertDir := filepath.Join(dir, signcerts)
	keystoreDir := filepath.Join(dir, keystore)
	bccspConfig = SetupBCCSPKeystoreConfig(bccspConfig, keystoreDir)

	err := factory.InitFactories(bccspConfig)
	if err != nil {
		return nil, errors.WithMessage(err, "could not initialize BCCSP Factories")
	}

	signcert, err := getPemMaterialFromDir(signcertDir)
	if err != nil {
		return nil, errors.Wrapf(err, "could not load signing certificate from directory %s", signcertDir)
	} else if len(signcert) == 0 {
		return nil, errors.Errorf("no signing certificate found in directory %s", signcertDir)

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Set the MSP type to 'fabric' (or 'idemix') in your config/env and retry
  2. Check ProviderTypeToString output in this version — match case and spelling exactly
  3. If using a custom BCCSP provider, configure it under bccsp config, not the MSP type
  4. Upgrade or patch the library if you need a provider type it does not support

Example fix

// before
mspConfig, err := GetLocalMspConfigWithType(dir, bccsp, "Org1", "bccsp")
// after
mspConfig, err := GetLocalMspConfigWithType(dir, bccsp, "Org1", "fabric")
Defensive patterns

Strategy: validation

Validate before calling

const allowed = map[string]bool{"fabric": true, "idemix": true}
if !allowed[strings.ToLower(mspType)] {
    return fmt.Errorf("unsupported MSP type %q; use \"fabric\" or \"idemix\"", mspType)
}

Type guard

func isKnownMSPType(t string) bool { return t == "fabric" || t == "idemix" }

Try / catch

cfg, err := GetLocalMspConfigWithType(dir, bccsp, id, mspType)
if err != nil && strings.Contains(err.Error(), "unknown MSP type") {
    return fmt.Errorf("config mspType=%q invalid; expected fabric|idemix", mspType)
}

Prevention

When it happens

Trigger: Calling GetLocalMspConfigWithType(dir, bccspConfig, ID, mspType) with a type string other than ProviderTypeToString(FABRIC) ('fabric') or ProviderTypeToString(IDEMIX) ('idemix') — e.g. via InitCrypto with a misconfigured msp.provider value.

Common situations: Setting CORE_LEDGER_STATE... or msp config 'mspType' to 'bccsp', 'softhsm', or a typo like 'fabrik'; copying config from a plugin example without registering a custom provider.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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