Wei-Shaw/sub2api · error
priority must be >= 0
Error message
priority must be >= 0
What it means
Thrown by the admin account import validator (validateAccountImportItem) when an imported account item has a Priority field below zero. The check runs after account-type and rate_multiplier/concurrency checks, guarding numeric sanity before accounts are persisted. It is a pure payload-validation error, not a system failure.
Source
Thrown at backend/internal/handler/admin/account_data.go:703
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")
}
if item.Concurrency < 0 {
return errors.New("concurrency must be >= 0")
}
if item.Priority < 0 {
return errors.New("priority must be >= 0")
}
return nil
}
func defaultProxyName(name string) string {
if strings.TrimSpace(name) == "" {
return "imported-proxy"
}
return name
}
// enrichCredentialsFromIDToken performs best-effort extraction of user info fields
// (email, plan_type, chatgpt_account_id, etc.) from id_token in credentials.
// Only applies to OpenAI OAuth accounts. Skips expired token errors silently.
// Existing credential values are never overwritten — only missing fields are filled.
func enrichCredentialsFromIDToken(item *DataAccount) {
if item.Credentials == nil {
returnView on GitHub (pinned to 073e92d171)
Solutions
- Set priority to 0 or a positive integer in the imported item and resubmit the import
- Check the preceding validation errors (account type, rate_multiplier, concurrency) in the same payload — they are validated first and may also fire
- If importing from CSV/JSON exports, sanitize numeric fields (clamp negatives to 0) before upload
Example fix
// before
{"type": "oauth", "name": "acct-1", "priority": -1}
// after
{"type": "oauth", "name": "acct-1", "priority": 0} Defensive patterns
Strategy: validation
Validate before calling
// Go: sanitize account import items before submit
for i := range items {
if items[i].Priority < 0 { items[i].Priority = 0 }
if items[i].Concurrency < 0 { items[i].Concurrency = 0 }
if items[i].RateMultiplier != nil && *items[i].RateMultiplier < 0 { items[i].RateMultiplier = nil }
} Prevention
- Clamp numeric account fields to non-negative before any import call
- Run imports through a dry-run/validate mode when the API offers one
- Keep export→import pipelines symmetric so sentinel values like -1 never enter payloads
When it happens
Trigger: POST/PUT to the admin account import endpoint with a JSON item whose priority is negative (e.g. "priority": -1). Also triggered by clients that model priority as a signed value and send -1 to mean 'lowest'.
Common situations: Bulk import scripts generated from spreadsheets containing negative numbers; UIs that allow -1 as a sentinel for 'no priority'; confusion with systems where lower number = higher priority and 0 is reserved.
Related errors
- 空 JSON 内容
- agent identity 缺少必要字段
- agent identity private key 格式无效
- 缺少 accessToken/access_token
- 未包含 refresh_token,且无法解析 accessToken 过期时间;请在第一步设置过期时间后再导入
AI-assisted analysis of Wei-Shaw/sub2api@073e92d171 (2026-08-15).
Data as JSON: /api/errors/19e05d91152d7201.
Report an issue: GitHub.