larksuite/cli · error

profile name %q is too long (max 64 characters)

Error message

profile name %q is too long (max 64 characters)

What it means

Guard in ValidateProfileName rejecting profile names longer than 64 characters. Fires from config init, profile add, and profile rename when the supplied name exceeds the storage/display length cap.

Source

Thrown at internal/core/config.go:166

// 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 {
	ProfileName         string
	AppID               string
	AppSecret           string

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Shorten the profile name to 64 runes or fewer
  2. Use a short name plus the profile's own description fields if supported
  3. Truncate programmatically by runes, not bytes

Example fix

// before
name := longString
err := core.ValidateProfileName(name)
// after
runes := []rune(longString)
if len(runes) > 64 { runes = runes[:64] }
err := core.ValidateProfileName(string(runes))
Defensive patterns

Strategy: validation

Validate before calling

runes := []rune(name)
if len(runes) > 64 {
    return fmt.Errorf("profile name must be at most 64 runes, got %d", len(runes))
}

Try / catch

if err := core.ValidateProfileName(name); err != nil {
    if strings.Contains(err.Error(), "too long") {
        name = string([]rune(name)[:64])
        if err := core.ValidateProfileName(name); err != nil { return err }
    }
}

Prevention

When it happens

Trigger: ValidateProfileName receives a name whose utf8.RuneCountInString exceeds 64 — commonly pasted long descriptions or generated names used as profiles.

Common situations: Pasting a sentence as a profile name; auto-generating names from tokens/emails that concatenate to >64 chars; CJK names counted by bytes elsewhere then assumed valid.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/b62df6d142364df8. Report an issue: GitHub.