{"id":"9c9625e822cd90ea","repo":"docker/cli","slug":"key-name-s-must-start-with-lowercase-alphanumer-9c9625","errorCode":null,"errorMessage":"key name \"%s\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character","messagePattern":"key name \"(.+?)\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/docker-trust/trust/key_load.go","lineNumber":49,"sourceCode":"\tvar options keyLoadOptions\n\tcmd := &cobra.Command{\n\t\tUse:   \"load [OPTIONS] KEYFILE\",\n\t\tShort: \"Load a private key file for signing\",\n\t\tArgs:  cli.ExactArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn loadPrivKey(dockerCLI, args[0], options)\n\t\t},\n\t\tDisableFlagsInUseLine: true,\n\t}\n\tflags := cmd.Flags()\n\tflags.StringVar(&options.keyName, \"name\", \"signer\", \"Name for the loaded key\")\n\treturn cmd\n}\n\nfunc loadPrivKey(streams command.Streams, keyPath string, options keyLoadOptions) error {\n\t// validate the key name if provided\n\tif options.keyName != \"\" && !validKeyName(options.keyName) {\n\t\treturn fmt.Errorf(\"key name \\\"%s\\\" must start with lowercase alphanumeric characters and can include \\\"-\\\" or \\\"_\\\" after the first character\", options.keyName)\n\t}\n\ttrustDir := trust.GetTrustDirectory()\n\tkeyFileStore, err := storage.NewPrivateKeyFileStorage(trustDir, notary.KeyExtension)\n\tif err != nil {\n\t\treturn err\n\t}\n\tprivKeyImporters := []trustmanager.Importer{keyFileStore}\n\n\t_, _ = fmt.Fprintf(streams.Out(), \"Loading key from \\\"%s\\\"...\\n\", keyPath)\n\n\t// Always use a fresh passphrase retriever for each import\n\tpassRet := trust.GetPassphraseRetriever(streams.In(), streams.Out())\n\tkeyBytes, err := getPrivKeyBytesFromPath(keyPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"refusing to load key from %s: %w\", keyPath, err)\n\t}\n\tif err := loadPrivKeyBytesToStore(keyBytes, privKeyImporters, keyPath, options.keyName, passRet); err != nil {\n\t\treturn fmt.Errorf(\"error importing key from %s: %w\", keyPath, err)","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cmd/docker-trust/trust/key_load.go#L31-L67","documentation":"Error \"key name \"%s\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character\" thrown in docker/cli.","triggerScenarios":"Thrown at cmd/docker-trust/trust/key_load.go:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}