larksuite/cli · warning
app registration cancelled: %w
Error message
app registration cancelled: %w
What it means
registrationContextError in internal/auth returns this error when the registration context was cancelled for a reason other than deadline expiry (e.g. parent cancellation). It wraps ctx.Err() so the root cause (context.Canceled) remains detectable via errors.Is.
Source
Thrown at internal/auth/app_registration.go:57
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 string
UserInfo *AppRegUserInfo
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Check errors.Is(err, context.Canceled) to distinguish user-initiated cancellation
- Ensure your program does not cancel the shared context prematurely before registration finishes
- Handle SIGINT/shutdown gracefully and treat this error as an aborted registration, not a bug
- If cancellation is unexpected, audit which parent context is passed to RegisterAppWithDiscovery
Example fix
// before: shared request context cancelled by an unrelated call ctx := reqCtx // after: dedicated context for registration regCtx, regCancel := context.WithCancel(context.Background()) defer regCancel()
Defensive patterns
Strategy: try-catch
Try / catch
err := auth.RegisterAppWithDiscovery(ctx, ...)
if errors.Is(err, context.Canceled) {
// registration aborted by the caller; treat as user-initiated stop
} Prevention
- Pass a context dedicated to registration, not a shared request context
- Handle SIGINT and cancel intentionally rather than tearing down parents
- Document cancellation semantics for long-running auth flows
- Check parent context cancellation before starting registration
When it happens
Trigger: The caller's context passed into RegisterAppWithDiscovery is cancelled while registration is in flight — user abort, parent shutdown, or an explicit cancel() call — and the deadline branch does not match.
Common situations: Ctrl-C / SIGINT during interactive app registration; a parent command being cancelled; the caller cancelling after losing interest without intending a timeout.
Related errors
- %w: %w
- stored token data is corrupt
- failed to parse user info: %w
- failed to get user info [%d]: %s
- failed to get user info: missing open_id in response
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/596a66b314e4d891.
Report an issue: GitHub.