{"record":{"id":"61a0c4170b0bb11b","repo":"larksuite/cli","slug":"name-q-must-not-contain","errorCode":null,"errorMessage":"name %q must not contain '='","messagePattern":"name %q must not contain '='","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flagalias/flagalias.go","lineNumber":280,"sourceCode":"\ttracked := &trackedValue{Value: flag.Value, canonical: flag.Name}\n\tif slice, ok := flag.Value.(pflag.SliceValue); ok {\n\t\tflag.Value = &trackedSliceValue{trackedValue: tracked, slice: slice}\n\t} else {\n\t\tflag.Value = tracked\n\t}\n\treturn tracked\n}\n\nfunc validateAliasName(name string) error {\n\tswitch {\n\tcase name == \"\":\n\t\treturn fmt.Errorf(\"name must not be empty\")\n\tcase strings.HasPrefix(name, \"-\"):\n\t\treturn fmt.Errorf(\"name %q must not include leading dashes\", name)\n\tcase strings.ContainsAny(name, \" \\t\\r\\n\"):\n\t\treturn fmt.Errorf(\"name %q must not contain whitespace\", name)\n\tcase strings.Contains(name, \"=\"):\n\t\treturn fmt.Errorf(\"name %q must not contain '='\", name)\n\tdefault:\n\t\treturn nil\n\t}\n}\n\nfunc collectRegistered(dst map[string]string, set *pflag.FlagSet) {\n\tif set == nil {\n\t\treturn\n\t}\n\tset.VisitAll(func(flag *pflag.Flag) {\n\t\tdst[flag.Name] = flag.Name\n\t})\n}\n\nfunc collectAnnotatedAliases(dst map[string]string, set *pflag.FlagSet, normalize func(string) string) {\n\tif set == nil {\n\t\treturn\n\t}","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/flagalias/flagalias.go#L262-L298","documentation":"validateAliasName rejects names containing '=' because '=' is the flag=value assignment token in pflag/cobra syntax. An alias name with '=' would collide with value-assignment parsing and could never be resolved as a plain flag name, so Bind fails fast at registration. This typically means an \"NAME=VALUE\" style string was passed where only the NAME belongs.","triggerScenarios":"Calling flagalias.Bind with a Spec name derived from an env-var-style or key=value string, e.g. Name: \"output=json\", or splitting a config entry on the wrong delimiter so the value stays attached to the name.","commonSituations":"Parsing a .env or properties file and passing whole lines as names; users writing \"--flag=value\" into a custom-alias config field; joining name and default value into one string before building the Spec.","solutions":["Split the string on '=' and use only the left side as the Spec name (strings.Cut(s, \"=\")).","If the intent is a default value, set it via the flag's default-value mechanism, not the alias name.","Reject or warn on key=value entries at config load so malformed entries never reach Bind.","Remember defaults may legitimately contain '='; only the NAME side must be '='-free."],"exampleFix":"// before\nname := entry // e.g. \"output=json\"\nspecs = append(specs, flagalias.Spec{Name: name, Target: target})\n// after\nname, _, _ := strings.Cut(entry, \"=\")\nspecs = append(specs, flagalias.Spec{Name: name, Target: target})","handlingStrategy":"validation","validationCode":"// split KEY=VALUE input before building specs:\nname, value, hasValue := strings.Cut(entry, \"=\")\nif hasValue {\n\t// use value as a default, never part of the name\n}\nif strings.Contains(name, \"=\") {\n\treturn fmt.Errorf(\"alias name %q contains '='\", name)\n}","typeGuard":"func isCleanFlagToken(s string) bool {\n\treturn s != \"\" && !strings.ContainsAny(s, \"= \\t\\r\\n\") && !strings.HasPrefix(s, \"-\")\n}","tryCatchPattern":null,"preventionTips":["Treat any KEY=VALUE string as two fields; only the KEY is a valid name.","Express defaults through the flag's default value, not the alias name.","Reuse one shared isCleanFlagToken check for all spec names so all four rules stay in sync."],"tags":["go","cli","flags","input-validation"],"backgroundTag":"invalid-flag-name","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"}