CherryHQ/cherry-studio · warning · Error

Feishu app registration QR code expired

Error message

Feishu app registration QR code expired

What it means

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.

Source

Thrown at src/main/ai/channels/adapters/feishu/FeishuAppRegistration.ts:128

      return {
        appId: res.client_id as string,
        appSecret: res.client_secret as string,
        openId: userInfo?.open_id
      }
    }

    // Handle error states
    const error = (res.error as string) ?? ''
    switch (error as PollStatus) {
      case 'authorization_pending':
        continue
      case 'slow_down':
        interval += 5000
        continue
      case 'access_denied':
        throw new Error('User denied the Feishu app registration')
      case 'expired_token':
        throw new Error('Feishu app registration QR code expired')
      default:
        if (error) {
          throw new Error(`Feishu registration poll error: ${error}`)
        }
        continue
    }
  }

  throw new Error('Feishu app registration timed out')
}

View on GitHub (pinned to 726446b54c)

Solutions

  1. Regenerate the QR (call registrationBegin again) and restart polling with a fresh device_code.
  2. Show a countdown on the QR screen so users know the time limit.
  3. Start polling immediately when the QR is shown, not after a delay.
Defensive patterns

Strategy: retry

Validate before calling

// Show a countdown so users act within the QR validity window.
startQrCountdown(expiresIn)

Type guard

function isFeishuQrExpired(e: unknown): e is Error {
  return e instanceof Error && e.message === 'Feishu app registration QR code expired'
}

Try / catch

try {
  await registrationPoll(domain, deviceCode, opts)
} catch (e) {
  if (isFeishuQrExpired(e)) { return restartRegistrationFlow() } // fresh QR
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: User walked away from the QR screen, or the device code was generated long before display.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/b75bcbcbc755fb12. Report an issue: GitHub.