{"record":{"id":"e0657b9fc5eb7c73","repo":"larksuite/cli","slug":"profile-name-cannot-be-empty","errorCode":null,"errorMessage":"profile name cannot be empty","messagePattern":"profile name cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/core/config.go","lineNumber":163,"sourceCode":"\t}\n\treturn -1\n}\n\n// ProfileNames returns all profile names (Name if set, otherwise AppId).\nfunc (m *MultiAppConfig) ProfileNames() []string {\n\tnames := make([]string, len(m.Apps))\n\tfor i := range m.Apps {\n\t\tnames[i] = m.Apps[i].ProfileName()\n\t}\n\treturn names\n}\n\n// ValidateProfileName checks that a profile name is valid.\n// Rejects empty names, whitespace, control characters, and shell-problematic characters,\n// but allows Unicode letters (e.g. Chinese, Japanese) for localized profile names.\nfunc ValidateProfileName(name string) error {\n\tif name == \"\" {\n\t\treturn fmt.Errorf(\"profile name cannot be empty\")\n\t}\n\tif utf8.RuneCountInString(name) > 64 {\n\t\treturn fmt.Errorf(\"profile name %q is too long (max 64 characters)\", name)\n\t}\n\tfor _, r := range name {\n\t\tif r <= 0x1F || r == 0x7F { // control characters\n\t\t\treturn fmt.Errorf(\"invalid profile name %q: contains control characters\", name)\n\t\t}\n\t\tswitch r {\n\t\tcase ' ', '\\t', '/', '\\\\', '\"', '\\'', '`', '$', '#', '!', '&', '|', ';', '(', ')', '{', '}', '[', ']', '<', '>', '?', '*', '~':\n\t\t\treturn fmt.Errorf(\"invalid profile name %q: contains invalid character %q\", name, r)\n\t\t}\n\t}\n\treturn nil\n}\n\n// CliConfig is the resolved single-app config used by downstream code.\ntype CliConfig struct {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/core/config.go#L145-L181","documentation":"Generic guard in ValidateProfileName rejecting an empty profile-name string. Fires when config init, profile add, or profile rename supplies a blank name; a non-empty, shell-safe name is required.","triggerScenarios":"Calling lark-cli auth init/add/rename (configInitRun, profileAddRun, profileRenameRun) with an empty --profile flag or an empty name variable.","commonSituations":"Script passes an unset variable as profile name; a flag defaulted to empty string; shell quoting dropped the argument entirely.","solutions":["Pass a non-empty profile name, e.g. --profile work","Check the script variable feeding the flag is set (\"${NAME:?unset}\")","Give the profile a default in your wrapper script instead of an empty string"],"exampleFix":"// before\nlark-cli auth add --profile \"$PROFILE\"\n// after\nlark-cli auth add --profile \"${PROFILE:?profile name required}\"","handlingStrategy":"validation","validationCode":"if profile == \"\" {\n    return errors.New(\"--profile is required\")\n}\nif err := core.ValidateProfileName(profile); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := core.ValidateProfileName(name); err != nil {\n    fmt.Fprintf(os.Stderr, \"invalid --profile: %v\\n\", err)\n    os.Exit(2)\n}","preventionTips":["Always pass --profile explicitly in scripts","Use ${VAR:?msg} to fail fast on unset variables","Never default profile flags to empty strings"],"tags":["go","cli","config","profile"],"backgroundTag":"empty-profile-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"}