larksuite/cli · error
profile name cannot be empty
Error message
profile name cannot be empty
What it means
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.
Source
Thrown at internal/core/config.go:163
}
return -1
}
// ProfileNames returns all profile names (Name if set, otherwise AppId).
func (m *MultiAppConfig) ProfileNames() []string {
names := make([]string, len(m.Apps))
for i := range m.Apps {
names[i] = m.Apps[i].ProfileName()
}
return names
}
// ValidateProfileName checks that a profile name is valid.
// Rejects empty names, whitespace, control characters, and shell-problematic characters,
// but allows Unicode letters (e.g. Chinese, Japanese) for localized profile names.
func ValidateProfileName(name string) error {
if name == "" {
return fmt.Errorf("profile name cannot be empty")
}
if utf8.RuneCountInString(name) > 64 {
return fmt.Errorf("profile name %q is too long (max 64 characters)", name)
}
for _, r := range name {
if r <= 0x1F || r == 0x7F { // control characters
return fmt.Errorf("invalid profile name %q: contains control characters", name)
}
switch r {
case ' ', '\t', '/', '\\', '"', '\'', '`', '$', '#', '!', '&', '|', ';', '(', ')', '{', '}', '[', ']', '<', '>', '?', '*', '~':
return fmt.Errorf("invalid profile name %q: contains invalid character %q", name, r)
}
}
return nil
}
// CliConfig is the resolved single-app config used by downstream code.
type CliConfig struct {View on GitHub (pinned to 7fd6ef3c07)
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
Example fix
// before
lark-cli auth add --profile "$PROFILE"
// after
lark-cli auth add --profile "${PROFILE:?profile name required}" Defensive patterns
Strategy: validation
Validate before calling
if profile == "" {
return errors.New("--profile is required")
}
if err := core.ValidateProfileName(profile); err != nil {
return err
} Try / catch
if err := core.ValidateProfileName(name); err != nil {
fmt.Fprintf(os.Stderr, "invalid --profile: %v\n", err)
os.Exit(2)
} Prevention
- Always pass --profile explicitly in scripts
- Use ${VAR:?msg} to fail fast on unset variables
- Never default profile flags to empty strings
When it happens
Trigger: Calling lark-cli auth init/add/rename (configInitRun, profileAddRun, profileRenameRun) with an empty --profile flag or an empty name variable.
Common situations: Script passes an unset variable as profile name; a flag defaulted to empty string; shell quoting dropped the argument entirely.
Related errors
- Invalid column: {column!r}
- Invalid column index: {index}
- anchor outside sheet: {position!r}
- Missing row_count/column_count for sheet {sheet_title(sheet)
- invalid --param format
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/e0657b9fc5eb7c73.
Report an issue: GitHub.