{"record":{"id":"0a560b4db3310d9c","repo":"decolua/9router","slug":"machine-id-is-required","errorCode":null,"errorMessage":"Machine ID is required","messagePattern":"Machine ID is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/oauth/services/cursor.js","lineNumber":102,"sourceCode":"    }\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.\n    // Token will be validated when used for actual requests.\n\n    return {\n      accessToken,","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/lib/oauth/services/cursor.js#L84-L120","documentation":"Second guard in CursorService.validateImportToken() (src/lib/oauth/services/cursor.js:102): the machineId argument is missing, empty, or not a string. The machine ID (storage.serviceMachineId from state.vscdb) is required because Cursor requests are authenticated with a checksum derived from it via generateChecksum().","triggerScenarios":"Calling validateImportToken(accessToken, undefined | null | '' | non-string) — e.g. the sqlite query for key 'storage.serviceMachineId' returned no row, the form import UI submitted a blank machine-ID field, or the value was parsed as a JSON object rather than a string.","commonSituations":"The user copied only the access token from the sqlite instructions and skipped step 4; a fresh Cursor install has not yet written storage.serviceMachineId; reading the DB from a script that only selected the accessToken key.","solutions":["Read the machine ID with: sqlite3 state.vscdb \"SELECT value FROM itemTable WHERE key='storage.serviceMachineId'\" and pass it as the second argument.","Confirm Cursor has been launched at least once so the machine-ID row is populated.","Ensure the value is a string (Buffer values need .toString('utf8')).","Check both values with one query: sqlite3 state.vscdb \"SELECT key, value FROM itemTable WHERE key IN ('cursorAuth/accessToken','storage.serviceMachineId')\"."],"exampleFix":"// before\nawait cursorService.validateImportToken(token, machineIdRow?.value);\n// after\nconst machineId = machineIdRow?.value?.toString?.(\"utf8\") ?? machineIdRow?.value;\nif (!machineId) throw new Error(\"storage.serviceMachineId not found in state.vscdb\");\nawait cursorService.validateImportToken(token, machineId);","handlingStrategy":"validation","validationCode":"const mid = machineIdFromVscdb;\nif (typeof mid !== \"string\" || mid.length === 0) {\n  throw new Error(\"storage.serviceMachineId missing — run: sqlite3 state.vscdb \\\"SELECT value FROM itemTable WHERE key='storage.serviceMachineId'\\\"\");\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 === \"Machine ID is required\") {\n    console.error(\"Machine ID not supplied. Fetch storage.serviceMachineId from state.vscdb and pass it as the 2nd argument.\");\n  } else throw err;\n}","preventionTips":["Follow both sqlite steps — token AND machine ID — from getTokenStorageInstructions().","Launch Cursor at least once so the machine-ID row exists.","Coerce driver values to strings (Buffer -> .toString('utf8')).","Trim shell output before passing values into the API."],"tags":["validation","cursor","machine-id","import"],"backgroundTag":"missing-required-parameter","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}