{"record":{"id":"4ecae9dba6d24ab8","repo":"larksuite/cli","slug":"alias-d-name-q-is-invalid","errorCode":null,"errorMessage":"alias[%d] name %q is invalid","messagePattern":"alias\\[(.+?)\\] name %q is invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":344,"sourceCode":"\t\t\treturn fmt.Errorf(\"encoding comma_or_repeated only supports string or integer arrays\")\n\t\t}\n\t\tif field.nullable != nil {\n\t\t\treturn fmt.Errorf(\"encoding comma_or_repeated does not allow nullable/nonnullable\")\n\t\t}\n\tcase typedEncodingJSON:\n\t\tif kind != reflect.Slice && kind != reflect.Array && kind != reflect.Struct && kind != reflect.Map && kind != reflect.Interface {\n\t\t\treturn fmt.Errorf(\"encoding json requires array, object, oneOf, or custom JSON input\")\n\t\t}\n\t\tif isNilCapable(field.valueType) && field.nullable == nil && !field.shapeExplicit && !shapeExplicitlyNullable(field.shape) {\n\t\t\treturn fmt.Errorf(\"nil-capable encoding=json input must declare nullable or nonnullable\")\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown CLI encoding %q\", field.cli.Encoding)\n\t}\n\tseenAliases := make(map[string]struct{})\n\tfor i, alias := range field.cli.Aliases {\n\t\tif !aliasNamePattern.MatchString(alias.Name) {\n\t\t\treturn fmt.Errorf(\"alias[%d] name %q is invalid\", i, alias.Name)\n\t\t}\n\t\tif alias.Name == field.name {\n\t\t\treturn fmt.Errorf(\"alias[%d] duplicates canonical flag --%s\", i, field.name)\n\t\t}\n\t\tif _, duplicate := seenAliases[alias.Name]; duplicate {\n\t\t\treturn fmt.Errorf(\"duplicate alias --%s\", alias.Name)\n\t\t}\n\t\tseenAliases[alias.Name] = struct{}{}\n\t\tswitch alias.Mode {\n\t\tcase typedAliasNormalize:\n\t\t\tif alias.Conflict != \"\" {\n\t\t\t\treturn fmt.Errorf(\"normalize alias --%s cannot declare Conflict\", alias.Name)\n\t\t\t}\n\t\t\tif alias.Deprecated {\n\t\t\t\treturn fmt.Errorf(\"deprecated alias --%s must use independent mode so Cobra can emit its warning\", alias.Name)\n\t\t\t}\n\t\tcase typedAliasIndependent:\n\t\t\tswitch alias.Conflict {","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L326-L362","documentation":"Each alias declared in the cli tag must match aliasNamePattern (a restricted flag-name grammar). An alias name with illegal characters, leading/trailing dashes, spaces, or uppercase characters is rejected with its index and value.","triggerScenarios":"cli tag declares an alias like `-t` (extra leading dash), `my Alias` (space), `CamelCase`, or `user.email`; aliasNamePattern.MatchString fails during validateInputCLI.","commonSituations":"Hand-writing aliases with punctuation or mixed case; assuming alias names follow the same leniency as arbitrary strings; including the -- prefix in the alias name.","solutions":["Rewrite the alias to a lowercase kebab-style flag name matching aliasNamePattern (no -- prefix, no spaces/symbols beyond the allowed set).","Check the pattern definition near the top of typed_compile_args.go for the exact grammar.","Drop the alias if a legal name is not needed; the canonical flag already works."],"exampleFix":"// before\ncli:\"alias=Camel Alias\"\n// after\ncli:\"alias=camel-alias\"","handlingStrategy":"validation","validationCode":"var aliasNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`) // confirm exact pattern in typed_compile_args.go\nfunc validAliasName(name string) error {\n\tif !aliasNamePattern.MatchString(name) {\n\t\treturn fmt.Errorf(\"alias %q invalid: use lowercase kebab, no -- prefix\", name)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write aliases as lowercase kebab tokens without the leading dashes.","Validate tag strings in a unit test; Go does not type-check tag contents.","Copy alias syntax from existing tags rather than writing from memory."],"tags":["cli","alias","naming","authoring-time"],"backgroundTag":"invalid-cli-tag-encoding","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}