{"id":"1269cc48dad5fc76","repo":"docker/cli","slug":"key-name-s-must-start-with-lowercase-alphanumer","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_generate.go","lineNumber":50,"sourceCode":"\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.name = args[0]\n\t\t\treturn setupPassphraseAndGenerateKeys(dockerCLI, options)\n\t\t},\n\t\tDisableFlagsInUseLine: true,\n\t}\n\tflags := cmd.Flags()\n\tflags.StringVar(&options.directory, \"dir\", \"\", \"Directory to generate key in, defaults to current directory\")\n\treturn cmd\n}\n\n// key names can use lowercase alphanumeric + _ + - characters\nvar validKeyName = lazyregexp.New(`^[a-z0-9][a-z0-9\\_\\-]*$`).MatchString\n\n// validate that all of the key names are unique and are alphanumeric + _ + -\n// and that we do not already have public key files in the target dir on disk\nfunc validateKeyArgs(keyName string, targetDir string) error {\n\tif !validKeyName(keyName) {\n\t\treturn fmt.Errorf(\"key name \\\"%s\\\" must start with lowercase alphanumeric characters and can include \\\"-\\\" or \\\"_\\\" after the first character\", keyName)\n\t}\n\n\tpubKeyFileName := keyName + \".pub\"\n\tif _, err := os.Stat(targetDir); err != nil {\n\t\treturn fmt.Errorf(\"public key path does not exist: \\\"%s\\\"\", targetDir)\n\t}\n\ttargetPath := filepath.Join(targetDir, pubKeyFileName)\n\tif _, err := os.Stat(targetPath); err == nil {\n\t\treturn fmt.Errorf(\"public key file already exists: \\\"%s\\\"\", targetPath)\n\t}\n\treturn nil\n}\n\nfunc setupPassphraseAndGenerateKeys(streams command.Streams, opts keyGenerateOptions) error {\n\ttargetDir := opts.directory\n\tif targetDir == \"\" {\n\t\tcwd, err := os.Getwd()\n\t\tif err != nil {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cmd/docker-trust/trust/key_generate.go#L32-L68","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_generate.go:50 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}