{"record":{"id":"6d303741b728b629","repo":"ipfs/kubo","slug":"unrecognized-import-format-s","errorCode":null,"errorMessage":"unrecognized import format: %s","messagePattern":"unrecognized import format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keystore.go","lineNumber":525,"sourceCode":"\t\t\t}\n\n\t\t\tsk, _, err = crypto.KeyPairFromStdKey(stdKey)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"converting std Go key to libp2p key: %w\", err)\n\t\t\t}\n\t\tcase keyFormatLibp2pCleartextOption:\n\t\t\tsk, err = crypto.UnmarshalPrivateKey(data)\n\t\t\tif err != nil {\n\t\t\t\t// check if data is PEM, if so, provide user with hint\n\t\t\t\tpemBlock, _ := pem.Decode(data)\n\t\t\t\tif pemBlock != nil {\n\t\t\t\t\treturn fmt.Errorf(\"unexpected PEM block for format=%s: try again with format=%s\", keyFormatLibp2pCleartextOption, keyFormatPemCleartextOption)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"unable to unmarshall format=%s: %w\", keyFormatLibp2pCleartextOption, err)\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unrecognized import format: %s\", importFormat)\n\t\t}\n\n\t\t// We only allow importing keys of the same type we generate (see list in\n\t\t// https://github.com/ipfs/interface-go-ipfs-core/blob/1c3d8fc/options/key.go#L58-L60),\n\t\t// unless explicitly stated by the user.\n\t\tallowAnyKeyType, _ := req.Options[keyAllowAnyTypeOptionName].(bool)\n\t\tif !allowAnyKeyType {\n\t\t\tswitch t := sk.(type) {\n\t\t\tcase *crypto.RsaPrivateKey, *crypto.Ed25519PrivateKey, *crypto.Secp256k1PrivateKey:\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"key type %T is not allowed to be imported, only RSA, Ed25519, or Secp256k1;\"+\n\t\t\t\t\t\" use flag --%s if you are sure of what you're doing\",\n\t\t\t\t\tt, keyAllowAnyTypeOptionName)\n\t\t\t}\n\t\t}\n\n\t\tcfgRoot, err := cmdenv.GetConfigRoot(env)\n\t\tif err != nil {","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keystore.go#L507-L543","documentation":"Switch-default guard in `ipfs key import`: the value of the --format option is not one of the recognized import formats (pem-pkcs8-cleartext or libp2p-protobuf-cleartext). A plain sentinel error naming the unsupported format string; the input file was never parsed.","triggerScenarios":"`ipfs key import name -f pem key.pem`, `-f pkcs8`, `-f openssl`, or any typo/abbreviation of the two supported values.","commonSituations":"Guessing the flag value instead of copying it from `ipfs key import --help`; older scripts using format names from other tools.","solutions":["Pass --format=libp2p-protobuf-cleartext for keys exported by ipfs key export in default format","Pass --format=pem-pkcs8-cleartext for PEM PKCS8 private keys","Omit --format to use the default and check `ipfs key import --help` for valid values"],"exampleFix":"// before\n$ ipfs key import mykey -f pem key.pem\nError: unrecognized import format: pem\n// after\n$ ipfs key import mykey -f pem-pkcs8-cleartext key.pem","handlingStrategy":"validation","validationCode":"var validFormats = map[string]bool{\"libp2p-protobuf-cleartext\": true, \"pem-pkcs8-cleartext\": true}\nif !validFormats[format] {\n    return fmt.Errorf(\"unsupported --format %q; use libp2p-protobuf-cleartext or pem-pkcs8-cleartext\", format)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy the format value verbatim from `ipfs key import --help`","Keep format strings in a constants block in scripts","Do not abbreviate format names"],"tags":["keystore","cli-usage","bad-argument","key-import"],"backgroundTag":"invalid-flag-value","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}