ipfs/kubo · error

please specify a key type with --type

Error message

please specify a key type with --type

What it means

Validation guard in `ipfs key add`/`key gen` option parsing: the --type option value was not a string, meaning the user supplied a key type that could not be read as text (typically an empty or malformed option). It is a plain sentinel error telling the caller to pass --type=rsa|ed25519|secp256k1 explicitly.

Source

Thrown at core/commands/keystore.go:110

		Tagline: "Create a new keypair",
	},
	Options: []cmds.Option{
		cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519, secp256k1").WithDefault(keyStoreAlgorithmDefault),
		cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
		ke.OptionIPNSBase,
	},
	Arguments: []cmds.Argument{
		cmds.StringArg("name", true, false, "name of key to create"),
	},
	Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
		api, err := cmdenv.GetApi(env, req)
		if err != nil {
			return err
		}

		typ, f := req.Options[keyStoreTypeOptionName].(string)
		if !f {
			return errors.New("please specify a key type with --type")
		}

		name := req.Arguments[0]
		if name == "self" {
			return errors.New("cannot create key with name 'self'")
		}

		opts := []options.KeyGenerateOption{options.Key.Type(typ)}

		size, sizefound := req.Options[keyStoreSizeOptionName].(int)
		if sizefound {
			opts = append(opts, options.Key.Size(size))
		}
		keyEnc, err := ke.KeyEncoderFromString(req.Options[ke.OptionIPNSBase.Name()].(string))
		if err != nil {
			return err
		}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Pass an explicit key type: ipfs key gen myname --type=ed25519
  2. Choose one of rsa, ed25519, or secp256k1
  3. Omit --type to use the configured default algorithm
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/commands/keystore.go:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/64c076fa1c13dc44. Report an issue: GitHub.