{"record":{"id":"05d965fd2a2b07ae","repo":"larksuite/cli","slug":"w-w","errorCode":null,"errorMessage":"%w: %w","messagePattern":"%w: %w","errorType":"exception","errorClass":"ErrRegistrationTimedOut","httpStatus":null,"severity":"error","filePath":"internal/auth/app_registration.go","lineNumber":55,"sourceCode":"func normalizedInterval(v int) int {\n\tif v <= 0 {\n\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","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/auth/app_registration.go#L37-L73","documentation":"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.","triggerScenarios":"RegisterAppWithDiscovery exceeds its configured timeout (context.WithDeadline/WithTimeout fires) before app registration completes, and the code calls registrationContextError with the expired context.","commonSituations":"Slow network or unreachable registration endpoint causing the device-code flow to outlive the deadline; an overly tight timeout in the caller's context.","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"],"exampleFix":"// before\nctx := context.Background()\n// after: generous registration timeout\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := auth.RegisterAppWithDiscovery(ctx, ...)\nif errors.Is(err, auth.ErrRegistrationTimedOut) {\n  // increase timeout or retry; cause is context.DeadlineExceeded\n}","preventionTips":["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"],"tags":["auth","timeout","context","app-registration"],"backgroundTag":"operation-deadline-exceeded","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"}