{"record":{"id":"bdd0d5408a96942c","repo":"larksuite/cli","slug":"alias-d-duplicates-canonical-flag-s","errorCode":null,"errorMessage":"alias[%d] duplicates canonical flag --%s","messagePattern":"alias\\[(.+?)\\] duplicates canonical flag --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":347,"sourceCode":"\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 {\n\t\t\tcase typedAliasCanonicalWins, typedAliasErrorIfBoth:\n\t\t\tcase typedAliasTrimmedEqualOrError:\n\t\t\t\tif indirectKind(field.valueType) != reflect.String {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L329-L365","documentation":"Validation in validateInputCLI: an alias spec re-declares the canonical flag it belongs to as one of its aliases. Aliases must differ from their canonical flag name.","triggerScenarios":"A cli tag declares alias=X on a field whose canonical name is X (e.g. field `verbose` with tag cli:\"alias=verbose\"); the alias.Name == field.name check fails.","commonSituations":"Adding an alias list and accidentally repeating the canonical name; refactoring a field rename so a former alias became the canonical name while still listed as an alias.","solutions":["Remove the redundant alias entry; the canonical flag is already registered.","Choose a genuinely different short/alternate name for the alias.","After field renames, audit cli tags so the old name stays only as an alias, not both."],"exampleFix":"// before\nVerbose bool `schema:\"optional\" cli:\"alias=verbose\"`\n// after\nVerbose bool `schema:\"optional\" cli:\"alias=v\"`","handlingStrategy":"validation","validationCode":"func aliasNotCanonical(fieldName, alias string) error {\n\tif alias == fieldName {\n\t\treturn fmt.Errorf(\"alias %q duplicates the canonical flag; remove it\", alias)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Aliases must add names, not repeat the field name.","After renaming a field, move the old name into aliases only once (as alias, not also canonical).","List each field's canonical name next to its aliases during review."],"tags":["cli","alias","duplicate-flag","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"}