{"record":{"id":"25c44ec8d1cbdb10","repo":"larksuite/cli","slug":"args-field-s-s-alias-s-duplicates-s","errorCode":null,"errorMessage":"Args field %s (--%s): alias --%s duplicates %s","messagePattern":"Args field (.+?) \\(--(.+?)\\): alias --(.+?) duplicates (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":67,"sourceCode":"\t\t}\n\t\tallNames[field.name] = \"--\" + field.name\n\t\tfieldByName[field.name] = i\n\t\tsupplement, hasSupplement := supplements[field.name]\n\t\tif hasSupplement {\n\t\t\tif err := mergeInputSupplement(field, supplement); err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"Args field %s (--%s): %w\", field.goName, field.name, err)\n\t\t\t}\n\t\t\tdelete(supplements, field.name)\n\t\t}\n\t\tif field.description == \"\" {\n\t\t\treturn nil, nil, fmt.Errorf(\"Args field %s (--%s): description is required via doc or InputField.Description\", field.goName, field.name)\n\t\t}\n\t\tif err := validateInputCLI(field); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"Args field %s (--%s): %w\", field.goName, field.name, err)\n\t\t}\n\t\tfor _, alias := range field.cli.Aliases {\n\t\t\tif previous, exists := allNames[alias.Name]; exists {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"Args field %s (--%s): alias --%s duplicates %s\", field.goName, field.name, alias.Name, previous)\n\t\t\t}\n\t\t\tallNames[alias.Name] = \"alias of --\" + field.name\n\t\t}\n\t}\n\tif len(supplements) > 0 {\n\t\tfor name := range supplements {\n\t\t\treturn nil, nil, fmt.Errorf(\"Input.Fields references unknown flag --%s\", name)\n\t\t}\n\t}\n\treturn fields, fieldByName, nil\n}\n\nfunc collectArgFields(t reflect.Type, parentIndex []int, insideInline bool, out *[]compiledInputField, seenGo map[string]struct{}, supplements map[string]typedInputField) error {\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\tif !field.IsExported() {\n\t\t\tif hasAnyTag(field, \"flag\", \"arg\", \"schema\", \"cli\", \"doc\", \"json\") {\n\t\t\t\treturn fmt.Errorf(\"Args field %s is unexported but declares Typed input tags\", field.Name)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L49-L85","documentation":"compileInput tracks all flag names and aliases in allNames and rejects any alias that collides with an already-registered flag, alias, or previously seen name. 'previous' records what claimed the name first (e.g. \"--other-flag\" or \"alias of --x\").","triggerScenarios":"Adding an alias in field.cli.Aliases that equals another field's flag name, another field's alias, or its own primary flag name, during compileInput.","commonSituations":"Adding short-form aliases like \"-u\" or \"u\" that collide with another flag; copy-pasting alias lists between fields; an alias intended as shorthand that accidentally matches an existing full flag name.","solutions":["Remove the colliding alias from field.cli.Aliases.","Rename the alias to a unique canonical name not used by any other flag or alias.","If the alias should replace the primary flag, change the flag tag instead of adding an alias."],"exampleFix":"// before\nUserID string `flag:\"user-id\" cli:\"aliases=[status]\"`\nStatus string `flag:\"status\"`\n// after\nUserID string `flag:\"user-id\"`\nStatus string `flag:\"status\"`","handlingStrategy":"validation","validationCode":"func aliasCollides(flags, aliases []string) error {\n  set := map[string]bool{}\n  for _, f := range flags { set[f] = true }\n  for _, a := range aliases {\n    if set[a] { return fmt.Errorf(\"alias --%s collides with a flag\", a) }\n    set[a] = true\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep aliases short and namespaced (e.g. single unique letters).","Never alias a flag to another flag's name.","Review alias lists when adding new fields."],"tags":["go","flags","aliases","collision"],"backgroundTag":"duplicate-flag-definition","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"}