{"record":{"id":"b75bcbcbc755fb12","repo":"CherryHQ/cherry-studio","slug":"feishu-app-registration-qr-code-expired","errorCode":null,"errorMessage":"Feishu app registration QR code expired","messagePattern":"Feishu app registration QR code expired","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ai/channels/adapters/feishu/FeishuAppRegistration.ts","lineNumber":128,"sourceCode":"      return {\n        appId: res.client_id as string,\n        appSecret: res.client_secret as string,\n        openId: userInfo?.open_id\n      }\n    }\n\n    // Handle error states\n    const error = (res.error as string) ?? ''\n    switch (error as PollStatus) {\n      case 'authorization_pending':\n        continue\n      case 'slow_down':\n        interval += 5000\n        continue\n      case 'access_denied':\n        throw new Error('User denied the Feishu app registration')\n      case 'expired_token':\n        throw new Error('Feishu app registration QR code expired')\n      default:\n        if (error) {\n          throw new Error(`Feishu registration poll error: ${error}`)\n        }\n        continue\n    }\n  }\n\n  throw new Error('Feishu app registration timed out')\n}\n","sourceCodeStart":110,"sourceCodeEnd":139,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/channels/adapters/feishu/FeishuAppRegistration.ts#L110-L139","documentation":"Thrown by registrationPoll() when the poll response carries error='expired_token'. The QR code/device code has a fixed validity (defaults to expires_in=600s); once elapsed, Feishu returns expired_token.","triggerScenarios":"User did not complete the QR scan within the validity window; the next poll returns {error:'expired_token'} and the switch throws before the local deadline is reached.","commonSituations":"User walked away from the QR screen, or the device code was generated long before display.","solutions":["Regenerate the QR (call registrationBegin again) and restart polling with a fresh device_code.","Show a countdown on the QR screen so users know the time limit.","Start polling immediately when the QR is shown, not after a delay."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Show a countdown so users act within the QR validity window.\nstartQrCountdown(expiresIn)","typeGuard":"function isFeishuQrExpired(e: unknown): e is Error {\n  return e instanceof Error && e.message === 'Feishu app registration QR code expired'\n}","tryCatchPattern":"try {\n  await registrationPoll(domain, deviceCode, opts)\n} catch (e) {\n  if (isFeishuQrExpired(e)) { return restartRegistrationFlow() } // fresh QR\n  throw e\n}","preventionTips":["Regenerate the QR via registrationBegin once expired_token fires.","Start polling immediately when the QR is shown.","Display the time limit to the user with a countdown."],"tags":["feishu","registration","expired","qr","oauth"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}