{"record":{"id":"0395fdadda861070","repo":"larksuite/cli","slug":"s-declares-aliases-for-unregistered-flag-s","errorCode":null,"errorMessage":"%s declares aliases for unregistered flag --%s","messagePattern":"(.+?) declares aliases for unregistered flag --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flagalias/flagalias.go","lineNumber":83,"sourceCode":"\tcollectRegistered(registered, cmd.InheritedFlags())\n\n\t// Existing annotations matter when Bind is composed by multiple adapters:\n\t// aliases are not independent pflags, so VisitAll alone cannot see them.\n\tacceptedAliases := make(map[string]string)\n\tcollectAnnotatedAliases(acceptedAliases, flagSet, normalize)\n\tcollectAnnotatedAliases(acceptedAliases, cmd.InheritedFlags(), normalize)\n\n\taliases := make(map[string]string)\n\tmetadata := make(map[*pflag.Flag][]string)\n\tcanonicalFlags := make(map[string]*pflag.Flag)\n\tseenCanonical := make(map[string]struct{})\n\tfor _, spec := range specs {\n\t\tif len(spec.Aliases) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcanonicalFlag := flagSet.Lookup(spec.Canonical)\n\t\tif canonicalFlag == nil {\n\t\t\treturn fmt.Errorf(\"%s declares aliases for unregistered flag --%s\", cmd.CommandPath(), spec.Canonical)\n\t\t}\n\t\tcanonical := canonicalFlag.Name\n\t\tif _, exists := seenCanonical[canonical]; exists {\n\t\t\treturn fmt.Errorf(\"%s declares flag aliases for --%s more than once after normalization\", cmd.CommandPath(), canonical)\n\t\t}\n\t\tseenCanonical[canonical] = struct{}{}\n\t\tcanonicalFlags[canonical] = canonicalFlag\n\t\tfor _, alias := range spec.Aliases {\n\t\t\tif err := validateAliasName(alias); err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s alias for --%s: %w\", cmd.CommandPath(), canonical, err)\n\t\t\t}\n\t\t\tnormalized := normalize(alias)\n\t\t\tif normalized == \"\" {\n\t\t\t\treturn fmt.Errorf(\"%s alias --%s for --%s normalizes to an empty name\", cmd.CommandPath(), alias, canonical)\n\t\t\t}\n\t\t\tif normalized == canonical {\n\t\t\t\treturn fmt.Errorf(\"%s declares --%s as an alias of itself (--%s after normalization)\", cmd.CommandPath(), alias, canonical)\n\t\t\t}","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/flagalias/flagalias.go#L65-L101","documentation":"Validation in Bind: a spec declares aliases for a canonical flag name that is not registered on the command (after normalization). The alias target must be an existing pflag; this catches typos or aliases declared before flag registration.","triggerScenarios":"Thrown at internal/flagalias/flagalias.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the canonical flag before binding aliases for it","Fix the canonical name spelling in the alias Spec"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}