larksuite/cli · error
invalid profile name %q: contains invalid character %q
Error message
invalid profile name %q: contains invalid character %q
What it means
Beyond control characters, ValidateProfileName rejects shell-problematic characters: whitespace, path separators, quotes, and metacharacters ($ ` # ! & | ; parentheses braces brackets < > ? * ~), keeping profile names safe in config keys and shell usage.
Source
Thrown at internal/core/config.go:174
}
// 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 {
ProfileName string
AppID string
AppSecret string
Brand LarkBrand
DefaultAs Identity // AsUser | AsBot | AsAuto | "" (from config file)
UserOpenId string
UserName string
Lang i18n.Lang
SupportedIdentities uint8 `json:"-"` // bitflag: 1=user, 2=bot; set by credential provider
}
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove the offending character — prefer letters, digits, '-', '_', '.'
- Replace spaces with hyphens ("my-work")
- Sanitize generated names with a replacement pass before validation
Example fix
// before
name := "my work/profile"
// after
name := strings.NewReplacer(" ", "-", "/", "-").Replace("my work/profile") // "my-work-profile" Defensive patterns
Strategy: validation
Validate before calling
func safeProfileName(s string) bool {
for _, r := range s {
if strings.ContainsRune(" \t/\\\"'`$#!&|;(){}[]<>?*~", r) { return false }
}
return s != ""
} Try / catch
if err := core.ValidateProfileName(name); err != nil {
if strings.Contains(err.Error(), "invalid character") {
name = strings.Map(func(r rune) rune {
if strings.ContainsRune(" \t/\\\"'`$#!&|;(){}[]<>?*~", r) { return '-' }
return r
}, name)
return core.ValidateProfileName(name)
}
return err
} Prevention
- Use only [A-Za-z0-9._-] for profile names
- Never use emails or paths as profile names
- Run ValidateProfileName in CI for any script that generates profiles
When it happens
Trigger: A name containing any of ' ', \t, /, \\, quotes, backtick, $, #, !, &, |, ;, (), {}, [], <, >, ?, *, ~ is passed to ValidateProfileName.
Common situations: Using an email address as a profile name; a name with a space like "my work"; shell expansions embedded by double-quoted interpolation.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
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)
- Missing sheet_id for sheet {title!r}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/34276381550f8afe.
Report an issue: GitHub.