{"record":{"id":"355c4b61624c3635","repo":"decolua/9router","slug":"access-token-is-required-355c4b","errorCode":null,"errorMessage":"Access token is required","messagePattern":"Access token is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/oauth/services/cursor.js","lineNumber":98,"sourceCode":"      const arch = process.arch;\n      if (arch === \"x64\") return \"x86_64\";\n      if (arch === \"arm64\") return \"aarch64\";\n      return arch;\n    }\n    return \"x86_64\";\n  }\n\n  /**\n   * Validate and import token from Cursor IDE\n   * Note: We skip API validation because Cursor API uses complex protobuf format.\n   * Token will be validated when actually used for requests.\n   * @param {string} accessToken - Access token from state.vscdb\n   * @param {string} machineId - Machine ID from state.vscdb\n   */\n  async validateImportToken(accessToken, machineId) {\n    // Basic validation\n    if (!accessToken || typeof accessToken !== \"string\") {\n      throw new Error(\"Access token is required\");\n    }\n\n    if (!machineId || typeof machineId !== \"string\") {\n      throw new Error(\"Machine ID is required\");\n    }\n\n    // Token format validation (Cursor tokens are typically long strings)\n    if (accessToken.length < 50) {\n      throw new Error(\"Invalid token format. Token appears too short.\");\n    }\n\n    // Machine ID format validation (should be UUID-like)\n    const uuidRegex = /^[a-f0-9-]{32,}$/i;\n    if (!uuidRegex.test(machineId.replace(/-/g, \"\"))) {\n      throw new Error(\"Invalid machine ID format. Expected UUID format.\");\n    }\n\n    // Note: We don't validate against API because Cursor uses complex protobuf.","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/lib/oauth/services/cursor.js#L80-L116","documentation":"CursorService.validateImportToken() (src/lib/oauth/services/cursor.js:98) performs local-only validation of a token pair imported from Cursor IDE's state.vscdb SQLite database. This first guard fires when the accessToken argument is missing, empty, or not a string. No network call is made — it is pure input validation before the token is accepted.","triggerScenarios":"Calling validateImportToken(undefined | null | '' | non-string, machineId) — e.g. the sqlite query for key 'cursorAuth/accessToken' returned no row, the value was read as a Buffer/JSON object instead of a string, or the form field was submitted empty from the dashboard import UI.","commonSituations":"Cursor was never logged in so the DB row doesn't exist; the user pasted values into the wrong fields; a script read state.vscdb with sqlite3 and got NULL; reading the DB with a driver that returns Blobs which are not `typeof string`.","solutions":["Extract the token from state.vscdb with: sqlite3 state.vscdb \"SELECT value FROM itemTable WHERE key='cursorAuth/accessToken'\" and pass that exact string.","Log in to Cursor IDE first so the accessToken row exists, then re-import.","Coerce/check before calling: if (typeof token !== 'string' || !token) fix the extraction step.","If a driver returns a Buffer, call .toString('utf8') before passing it."],"exampleFix":"// before\nawait cursorService.validateImportToken(row?.value, machineId);\n// after\nconst token = typeof row?.value === \"string\" ? row.value : row?.value?.toString(\"utf8\");\nif (!token) throw new Error(\"cursorAuth/accessToken not found in state.vscdb — is Cursor logged in?\");\nawait cursorService.validateImportToken(token, machineId);","handlingStrategy":"validation","validationCode":"const token = valueFromVscdb;\nif (typeof token !== \"string\" || token.length === 0) {\n  throw new Error(\"cursorAuth/accessToken missing — run: sqlite3 state.vscdb \\\"SELECT value FROM itemTable WHERE key='cursorAuth/accessToken'\\\"\");\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === \"string\" && v.length > 0;\n}","tryCatchPattern":"try {\n  await cursorService.validateImportToken(token, machineId);\n} catch (err) {\n  if (err.message === \"Access token is required\") {\n    console.error(\"No access token supplied. Confirm Cursor is logged in and the state.vscdb row exists.\");\n  } else throw err;\n}","preventionTips":["Confirm Cursor IDE is logged in before attempting token import.","Convert Buffer/Blob values from your sqlite driver with .toString('utf8') before passing.","Validate both token and machineId in the import UI before invoking the service.","Use the documented one-liner sqlite query to fetch both values together."],"tags":["validation","cursor","oauth","import"],"backgroundTag":"missing-required-parameter","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}