{"record":{"id":"f4fc5f3bc7652683","repo":"QuantumNous/new-api","slug":"unsupported-verification-method-method","errorCode":null,"errorMessage":"Unsupported verification method: {{method}}","messagePattern":"Unsupported verification method: (.+?)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/features/auth/secure-verification/api.ts","lineNumber":89,"sourceCode":"    }\n  }\n}\n\n/**\n * Execute a verification flow based on the method type.\n */\nexport async function verify(\n  method: VerificationMethod,\n  scope: SecurityProofScope,\n  code?: string\n): Promise<SecurityProof> {\n  switch (method) {\n    case '2fa':\n      return verifyTwoFA(scope, code)\n    case 'passkey':\n      return verifyPasskey(scope)\n    default:\n      throw new Error(\n        i18next.t('Unsupported verification method: {{method}}', { method })\n      )\n  }\n}\n\n/**\n * Perform 2FA verification flow.\n */\nasync function verifyTwoFA(\n  scope: SecurityProofScope,\n  code?: string | null\n): Promise<SecurityProof> {\n  const trimmed = code?.trim()\n  if (!trimmed) {\n    throw new Error(\n      i18next.t('Please enter the verification code or backup code')\n    )\n  }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/features/auth/secure-verification/api.ts#L71-L107","documentation":"Thrown by verify() when the method argument does not match the '2fa' or 'passkey' case in the switch. The function only supports those two verification methods, and any other string falls through to the default branch. This is a programming/caller error or a data problem (an unvalidated method value from state), not a runtime environment issue.","triggerScenarios":"Calling verify(method, scope) with a string outside the VerificationMethod union (e.g. 'email', 'sms', empty string, undefined coerced to 'undefined'); passing state.method from a store that was never validated against the supported set.","commonSituations":"A new verification method is added to the backend and to persisted state but not to this switch; state restored from localStorage contains a legacy method value; typo in the method literal at a call site.","solutions":["Log or inspect the actual method value at the call site — it will be anything other than '2fa' or 'passkey'.","If you extended verification methods, add the new case to the switch in verify().","Validate method against the supported set before invoking verify() (see type guard below).","Clear persisted auth-verification state after schema changes so stale method values disappear."],"exampleFix":"// before\nverify(method, scope, code) // method = 'email' → default branch throws\n\n// after\nconst isVerificationMethod = (m: unknown): m is VerificationMethod =>\n  m === '2fa' || m === 'passkey'\nif (!isVerificationMethod(method)) {\n  throw new Error(`Unsupported verification method: ${String(method)}`)\n}\nawait verify(method, scope, code)","handlingStrategy":"type-guard","validationCode":"const SUPPORTED_METHODS = ['2fa', 'passkey'] as const\nif (!SUPPORTED_METHODS.includes(method)) {\n  toast.error(`Unsupported verification method: ${method}`)\n  return\n}","typeGuard":"const isVerificationMethod = (\n  m: unknown\n): m is '2fa' | 'passkey' => m === '2fa' || m === 'passkey'","tryCatchPattern":null,"preventionTips":["Type the method parameter as the literal union, never string","Validate persisted state.method against the supported set on restore","Update the switch in verify() in the same commit that adds a backend method"],"tags":["verification","typescript","switch-default","frontend"],"backgroundTag":null,"analyzedSha":"e2c7aa7b102c2075eae2377df3508658d45e88dc","analyzedAt":"2026-08-15T10:35:18.111Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}