jlcodes99/cockpit-tools · error

Qoder OAuth 授权链接为空

Error message

Qoder OAuth 授权链接为空

What it means

During the Qoder OAuth device-flow preparation, after requesting a device code the page expects a verification URI. If verificationUri is empty, it logs the raw response keys ('prepare:verification-uri-empty') and throws a plain Error('Qoder OAuth 授权链接为空' — Qoder OAuth authorization link is empty). This signals the provider returned a response without the required verification_uri field.

Source

Thrown at src/pages/QoderAccountsPage.tsx:1256

          loginId: response.loginId,
          attemptSeq,
        });
        return;
      }

      const loginId = response.loginId;
      const verificationUri =
        response.verificationUri ||
        (response as unknown as { verification_uri?: string }).verification_uri ||
        '';
      if (!verificationUri) {
        const responseKeys = Object.keys(response);
        logQoderOauthUi('prepare:verification-uri-empty', {
          loginId,
          responseKeyCount: responseKeys.length,
          responseKeys: responseKeys.slice(0, 12),
        });
        throw new Error('Qoder OAuth 授权链接为空');
      }
      logQoderOauthUi('prepare:will-set-state', {
        loginId,
        verificationUriLength: verificationUri.length,
        callbackUrl: response.callbackUrl ?? null,
        currentOauthSessionRef: oauthSessionRef.current,
      });
      oauthSessionRef.current = loginId;
      setOauthLoginId(loginId);
      setOauthUrl(verificationUri);
      setOauthPreparing(false);
      logQoderOauthUi('prepare:state-set-done', { loginId });
      startCompletePolling(loginId);
    } catch (error) {
      if (attemptSeq !== oauthAttemptSeqRef.current) return;
      logQoderOauthUi('prepare:start-failed', { error: String(error) });
      const msg = String(error);
      setOauthPreparing(false);

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Retry the OAuth preparation — a transient backend issue may return an incomplete response.
  2. Inspect the logged 'prepare:verification-uri-empty' entry (responseKeys) to see what the server actually returned.
  3. Check Qoder service status / API version compatibility if responses are consistently missing the field.
  4. Validate the response shape before use and surface a retry-able error to the user.

Example fix

// before
if (!verificationUri) {
  throw new Error('Qoder OAuth 授权链接为空');
}
// after
if (!verificationUri) {
  logQoderOauthUi('prepare:verification-uri-empty', { loginId });
  throw new RetryableError('Qoder OAuth 授权链接为空'); // caller retries prepare
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeof response.verificationUri !== 'string' || response.verificationUri.length === 0) {
  // abort and retry prepare
}

Type guard

const hasVerificationUri = (r: unknown): r is { verificationUri: string } & Record<string, unknown> =>
  typeof r === 'object' && r !== null &&
  typeof (r as any).verificationUri === 'string' &&
  (r as any).verificationUri.length > 0;

Try / catch

try {
  await startQoderOauthPrepare();
} catch (e) {
  if (e.message === 'Qoder OAuth 授权链接为空') {
    showRetryDialog(t('qoder.oauth.retryPrepare'));
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: The Qoder device-authorization endpoint responds with a 200 body that lacks verificationUri (or it is an empty string), so the check before entering the waiting/polling state throws.

Common situations: Qoder backend changes or partial outages returning malformed device-code responses; proxy/gateway stripping fields; API version drift between client and service; network middleware returning an unexpected success body.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/083518182a9f4145. Report an issue: GitHub.