larksuite/cli · error
app registration failed: %s
Error message
app registration failed: %s
What it means
Thrown by RequestAppRegistration at internal/auth/app_registration.go:140 when the begin response either has HTTP status >= 400 or contains an "error" field. The message carries the server's error_description (falling back to error, then 'Unknown error'). This is the library's generic surfaced server-side rejection of the registration initiation.
Source
Thrown at internal/auth/app_registration.go:140
if err != nil {
return nil, fmt.Errorf("app registration failed: read body: %w", err)
}
var data map[string]interface{}
if err := json.Unmarshal(body, &data); err != nil {
return nil, fmt.Errorf("app registration failed: HTTP %d – response not JSON", resp.StatusCode)
}
_, hasError := data["error"]
if resp.StatusCode >= 400 || hasError {
msg := getStr(data, "error_description")
if msg == "" {
msg = getStr(data, "error")
}
if msg == "" {
msg = "Unknown error"
}
return nil, fmt.Errorf("app registration failed: %s", msg)
}
// The protocol field is expire_in; accept the legacy expires_in spelling,
// then normalize to protocol defaults.
expiresIn := getInt(data, "expire_in", 0)
if expiresIn <= 0 {
expiresIn = getInt(data, "expires_in", 0)
}
expiresIn = normalizedExpireIn(expiresIn)
interval := normalizedInterval(getInt(data, "interval", 0))
deviceCode := getStr(data, "device_code")
if deviceCode == "" {
return nil, fmt.Errorf("app registration failed: response missing device_code")
}
userCode := getStr(data, "user_code")
verificationUri := getStr(data, "verification_uri")View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Read the %s text in the message — it is the server's error_description; fix the condition it names.
- If rate-limited, wait and retry after the indicated backoff period.
- Verify network region: some corporate egress IPs are blocked by the accounts service.
- Update the CLI — an outdated protocol request (archetype/auth_method fields) can be rejected by newer servers.
- If the message is 'Unknown error', capture logs (logHTTPResponse output) and report the issue with the HTTP status.
Defensive patterns
Strategy: try-catch
Try / catch
resp, err := RequestAppRegistration(ctx, client, brand, errOut)
if err != nil {
var msg string
if _, after, ok := strings.Cut(err.Error(), "app registration failed: "); ok {
msg = after // server-provided error_description; surface to the user
}
return fmt.Errorf("registration begin rejected: %s", msg)
} Prevention
- Rate-limit your own retries of the registration flow.
- Keep the CLI updated so begin-request protocol fields stay accepted.
- Register from an unblocked network region/IP.
When it happens
Trigger: Server responds 4xx/5xx (rate limit, bad request, unauthorized origin) or returns 200 with an OAuth-style error object such as {"error":"..."} during the 'begin' action of device registration.
Common situations: Server-side rate limiting after repeated registration attempts; blocked region or IP; deprecated/retired registration endpoint returning an error payload; service outage reporting errors in-band.
Related errors
- Device authorization failed: %s
- app registration failed: HTTP %d – response not JSON
- poll request: %w
- Device authorization failed: read body: %v
- Device authorization failed: HTTP %d – response not JSON
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/257e942cc8911e9e.
Report an issue: GitHub.