larksuite/cli · error · ErrRegistrationTimedOut
%w: %w
Error message
%w: %w
What it means
registrationContextError in internal/auth maps a done registration context to its terminal error. When the context deadline was exceeded, it returns ErrRegistrationTimedOut wrapped together with context.DeadlineExceeded, so callers can errors.Is-match either sentinel. The message format is the two-%w join of the timeout sentinel and the context error.
Source
Thrown at internal/auth/app_registration.go:55
func normalizedInterval(v int) int {
if v <= 0 {
return defaultPollIntervalSeconds
}
return v
}
// normalizedExpireIn clamps a non-positive expiry budget to the protocol default.
func normalizedExpireIn(v int) int {
if v <= 0 {
return defaultExpireInSeconds
}
return v
}
// registrationContextError maps a done context to its terminal reason, keeping the cause.
func registrationContextError(ctx context.Context) error {
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
return fmt.Errorf("%w: %w", ErrRegistrationTimedOut, ctx.Err())
}
return fmt.Errorf("app registration cancelled: %w", ctx.Err())
}
// AppRegistrationResponse is the response from the app registration begin endpoint.
type AppRegistrationResponse struct {
DeviceCode string
UserCode string
VerificationUri string
VerificationUriComplete string
ExpiresIn int
Interval int
}
// AppRegistrationResult is the result of a successful app registration poll.
type AppRegistrationResult struct {
ClientID string
ClientSecret stringView on GitHub (pinned to 7fd6ef3c07)
Solutions
- Increase the registration timeout/deadline passed to RegisterAppWithDiscovery
- Check network connectivity/latency to the Lark registration endpoint
- Detect this case with errors.Is(err, auth.ErrRegistrationTimedOut) and prompt the user to retry
- Investigate why registration stalled (device-code polling, upstream 5xx) via logs
Example fix
// before ctx := context.Background() // after: generous registration timeout ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel()
Defensive patterns
Strategy: try-catch
Try / catch
err := auth.RegisterAppWithDiscovery(ctx, ...)
if errors.Is(err, auth.ErrRegistrationTimedOut) {
// increase timeout or retry; cause is context.DeadlineExceeded
} Prevention
- Give device-code registration a generous timeout (>= several minutes)
- Monitor latency to the registration endpoint
- Surface ErrRegistrationTimedOut distinctly to users so they retry
- Avoid nested tight deadlines on the registration context
When it happens
Trigger: RegisterAppWithDiscovery exceeds its configured timeout (context.WithDeadline/WithTimeout fires) before app registration completes, and the code calls registrationContextError with the expired context.
Common situations: Slow network or unreachable registration endpoint causing the device-code flow to outlive the deadline; an overly tight timeout in the caller's context.
Related errors
- app registration cancelled: %w
- lark-cli timed out after {timeout}s
- stored token data is corrupt
- failed to parse user info: %w
- failed to get user info [%d]: %s
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/05d965fd2a2b07ae.
Report an issue: GitHub.