Wei-Shaw/sub2api · error
account name is required
Error message
account name is required
What it means
Returned by validateDataAccount (backend/internal/handler/admin/account_data.go:680) when an accounts[] entry's name is empty after TrimSpace. Name is the first per-account field checked, followed by platform, type, and credentials, so this error means the entry failed at the very first precondition.
Source
Thrown at backend/internal/handler/admin/account_data.go:680
return errors.New("proxy port is invalid")
}
switch item.Protocol {
case "http", "https", "socks5", "socks5h":
default:
return fmt.Errorf("proxy protocol is invalid: %s", item.Protocol)
}
if item.Status != "" {
normalizedStatus := normalizeProxyStatus(item.Status)
if normalizedStatus != service.StatusActive && normalizedStatus != "inactive" {
return fmt.Errorf("proxy status is invalid: %s", item.Status)
}
}
return nil
}
func validateDataAccount(item DataAccount) error {
if strings.TrimSpace(item.Name) == "" {
return errors.New("account name is required")
}
if strings.TrimSpace(item.Platform) == "" {
return errors.New("account platform is required")
}
if strings.TrimSpace(item.Type) == "" {
return errors.New("account type is required")
}
if len(item.Credentials) == 0 {
return errors.New("account credentials is required")
}
switch item.Type {
case service.AccountTypeOAuth, service.AccountTypeSetupToken, service.AccountTypeAPIKey, service.AccountTypeUpstream:
default:
return fmt.Errorf("account type is invalid: %s", item.Type)
}
if item.RateMultiplier != nil && *item.RateMultiplier < 0 {
return errors.New("rate_multiplier must be >= 0")
}View on GitHub (pinned to 073e92d171)
Solutions
- Set a non-empty name on every account entry (e.g. 'openai-main').
- If generating payloads, always emit a name — the import does not auto-generate one.
- Trim and check required fields client-side before submit.
Example fix
// before
{ "platform": "openai", "type": "oauth", "credentials": { ... } }
// after
{ "name": "openai-main", "platform": "openai", "type": "oauth", "credentials": { ... } } Defensive patterns
Strategy: validation
Validate before calling
function hasAccountName(entry: Record<string, unknown>): boolean {
return typeof entry.name === 'string' && entry.name.trim() !== ''
} Type guard
function hasRequiredAccountStrings(e: unknown, keys: string[]): e is Record<string, string> {
if (typeof e !== 'object' || e === null) return false
const o = e as Record<string, unknown>
return keys.every((k) => typeof o[k] === 'string' && (o[k] as string).trim() !== '')
} Prevention
- Generate a name (e.g. 'imported-account-N') when the source lacks one — the import does not auto-name.
- Require name/platform/type in the import UI.
- Trim all string fields before submit.
When it happens
Trigger: An account object with name missing, blank, or whitespace-only; a serializer dropping the name field for auto-named accounts.
Common situations: Minimal hand-written imports that skip display names; exports where name was optional; front-end form allowing empty name.
Related errors
- account platform is required
- account type is required
- account credentials is required
- rate_multiplier must be >= 0
- concurrency must be >= 0
AI-assisted analysis of Wei-Shaw/sub2api@073e92d171 (2026-08-15).
Data as JSON: /api/errors/e2d8237717b9a1c7.
Report an issue: GitHub.