{"record":{"id":"596a66b314e4d891","repo":"larksuite/cli","slug":"app-registration-cancelled-w","errorCode":null,"errorMessage":"app registration cancelled: %w","messagePattern":"app registration cancelled: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/auth/app_registration.go","lineNumber":57,"sourceCode":"\t\treturn defaultPollIntervalSeconds\n\t}\n\treturn v\n}\n\n// normalizedExpireIn clamps a non-positive expiry budget to the protocol default.\nfunc normalizedExpireIn(v int) int {\n\tif v <= 0 {\n\t\treturn defaultExpireInSeconds\n\t}\n\treturn v\n}\n\n// registrationContextError maps a done context to its terminal reason, keeping the cause.\nfunc registrationContextError(ctx context.Context) error {\n\tif errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\treturn fmt.Errorf(\"%w: %w\", ErrRegistrationTimedOut, ctx.Err())\n\t}\n\treturn fmt.Errorf(\"app registration cancelled: %w\", ctx.Err())\n}\n\n// AppRegistrationResponse is the response from the app registration begin endpoint.\ntype AppRegistrationResponse struct {\n\tDeviceCode              string\n\tUserCode                string\n\tVerificationUri         string\n\tVerificationUriComplete string\n\tExpiresIn               int\n\tInterval                int\n}\n\n// AppRegistrationResult is the result of a successful app registration poll.\ntype AppRegistrationResult struct {\n\tClientID     string\n\tClientSecret string\n\tUserInfo     *AppRegUserInfo\n}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/auth/app_registration.go#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"Ctrl-C / SIGINT during interactive app registration; a parent command being cancelled; the caller cancelling after losing interest without intending a timeout.","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"],"exampleFix":"// before: shared request context cancelled by an unrelated call\nctx := reqCtx\n// after: dedicated context for registration\nregCtx, regCancel := context.WithCancel(context.Background())\ndefer regCancel()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := auth.RegisterAppWithDiscovery(ctx, ...)\nif errors.Is(err, context.Canceled) {\n  // registration aborted by the caller; treat as user-initiated stop\n}","preventionTips":["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"],"tags":["auth","context","cancellation","app-registration"],"backgroundTag":"context-cancelled","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}