{"record":{"id":"653ae85003a9a055","repo":"QuantumNous/new-api","slug":"unable-to-parse-passkey-login-options-from-respons","errorCode":null,"errorMessage":"Unable to parse Passkey login options from response","messagePattern":"Unable to parse Passkey login options from response","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/lib/passkey.ts","lineNumber":163,"sourceCode":"  }\n\n  return publicKey\n}\n\n/**\n * Prepare credential request options returned by the backend.\n */\nexport function prepareCredentialRequestOptions(\n  payload: any\n): PublicKeyCredentialRequestOptions {\n  const options =\n    payload?.publicKey ??\n    payload?.PublicKey ??\n    payload?.response ??\n    payload?.Response\n\n  if (!options) {\n    throw new Error('Unable to parse Passkey login options from response')\n  }\n\n  const publicKey: PublicKeyCredentialRequestOptions & Record<string, any> = {\n    ...options,\n    challenge: base64UrlToArrayBuffer(options.challenge),\n  }\n\n  if (Array.isArray(options.allowCredentials)) {\n    publicKey.allowCredentials = options.allowCredentials.map((item: any) => ({\n      ...item,\n      id: base64UrlToArrayBuffer(item.id),\n    }))\n  }\n\n  return publicKey\n}\n\n/**","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/lib/passkey.ts#L145-L181","documentation":"Thrown by prepareCredentialRequestOptions in the passkey lib when the backend's login-options payload has none of the recognized carriers (publicKey, PublicKey, response, Response) for the WebAuthn PublicKeyCredentialRequestOptions. It mirrors the registration parser: without a challenge/options object, navigator.credentials.get cannot be invoked.","triggerScenarios":"beginPasskeyLogin succeeds but begin.data is undefined/an error body, or the options object is nested under a field the parser does not know; also when callers pass begin.data?.options ?? begin.data and both are empty.","commonSituations":"Login-begin endpoint returning success:true with empty data; API contract change moving options; proxy stripping the response body; session/CSRF failure returning an HTML page parsed into an unexpected object.","solutions":["Inspect the begin-passkey-login response in the network tab; confirm where the options object (with challenge) actually sits.","Ensure the begin request includes credentials/CSRF token so it returns real options rather than an auth-error envelope.","Align the parser with the backend contract or fix the backend to return options under publicKey; cover with a unit test using a captured fixture.","Catch the error and show 'Passkey login unavailable' with a password-login fallback."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (!begin.success || !begin.data?.options) {\n  // do not call prepareCredentialRequestOptions; surface begin.message instead\n}","typeGuard":"function hasRequestOptions(payload: any): boolean {\n  return Boolean(payload?.publicKey ?? payload?.PublicKey ?? payload?.response ?? payload?.Response)\n}","tryCatchPattern":"try {\n  const publicKey = prepareCredentialRequestOptions(begin.data?.options ?? begin.data)\n} catch (error) {\n  if (/Unable to parse Passkey login options/.test(error.message)) {\n    toast.error(t('Passkey login unavailable')); return // password login remains\n  }\n}","preventionTips":["Guard the begin envelope (success + data) before parsing options","Contract-test the begin endpoint's response shape in CI"],"tags":["passkey","webauthn","login","payload-shape"],"backgroundTag":null,"analyzedSha":"e2c7aa7b102c2075eae2377df3508658d45e88dc","analyzedAt":"2026-08-15T10:35:18.111Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}