{"record":{"id":"c25f54bd34670a1e","repo":"decolua/9router","slug":"invalid-machine-id-format-expected-uuid-format","errorCode":null,"errorMessage":"Invalid machine ID format. Expected UUID format.","messagePattern":"Invalid machine ID format\\. Expected UUID format\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/oauth/services/cursor.js","lineNumber":113,"sourceCode":"  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,\n      machineId,\n      expiresIn: 86400, // Cursor tokens typically last 24 hours\n      authMethod: \"imported\",\n    };\n  }\n\n  /**\n   * Extract user info from token if possible\n   * Cursor tokens may contain encoded user info\n   */\n  extractUserInfo(accessToken) {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/lib/oauth/services/cursor.js#L95-L131","documentation":"CursorService.validateImportToken() (src/lib/oauth/services/cursor.js:113) validates the machine ID against /^[a-f0-9-]{32,}$/i after stripping hyphens — i.e. it must be a UUID-like hex string of at least 32 characters. The value came from state.vscdb's storage.serviceMachineId but doesn't have that shape, so it can't be used to build the x-cursor-checksum header.","triggerScenarios":"Calling validateImportToken with a machineId that is not hex/UUID-like — e.g. a telemetry machineId, a MAC address with colons, a value wrapped in quotes or whitespace, an uppercase/non-hex identifier, or a numeric telemetry ID from a different Cursor storage key.","commonSituations":"The user grabbed the wrong machine ID (e.g. 'telemetry.machineId' instead of 'storage.serviceMachineId'); copy/paste included surrounding quotes; some Cursor builds store a differently formatted ID; trailing newline from shell output was not trimmed.","solutions":["Re-read the correct key: sqlite3 state.vscdb \"SELECT value FROM itemTable WHERE key='storage.serviceMachineId'\".","Trim whitespace and strip surrounding quotes before passing the value.","Check the format locally: /^[a-f0-9-]{32,}$/i.test(id.replace(/-/g, '')) must be true.","If your Cursor version stores a non-UUID serviceMachineId, use the telemetry.machineId UUID if present, or report the format so the regex can be relaxed."],"exampleFix":"// before\nawait cursorService.validateImportToken(token, machineId);\n// after\nconst id = String(machineId || \"\").trim().replace(/^[\"']|[\"']$/g, \"\");\nif (!/^[a-f0-9-]{32,}$/i.test(id.replace(/-/g, \"\"))) throw new Error(`Machine ID not UUID-like: ${id.slice(0, 8)}…`);\nawait cursorService.validateImportToken(token, id);","handlingStrategy":"validation","validationCode":"const id = String(rawMachineId || \"\").trim().replace(/^[\"']|[\"']$/g, \"\");\nif (!/^[a-f0-9-]{32,}$/i.test(id.replace(/-/g, \"\"))) {\n  throw new Error(`Machine ID is not UUID-like: \"${id}\" — did you read telemetry.machineId instead of storage.serviceMachineId?`);\n}","typeGuard":"function isUuidLikeMachineId(v) {\n  return typeof v === \"string\" && /^[a-f0-9-]{32,}$/i.test(v.replace(/-/g, \"\"));\n}","tryCatchPattern":"try {\n  await cursorService.validateImportToken(token, machineId);\n} catch (err) {\n  if (/Invalid machine ID format/.test(err.message)) {\n    console.error(\"Re-read storage.serviceMachineId (not telemetry.machineId); trim quotes/whitespace.\");\n  } else throw err;\n}","preventionTips":["Always use the exact key storage.serviceMachineId from itemTable.","Trim and de-quote shell/DB output before use.","Pre-validate with the same regex the service uses: hex, >= 32 chars after hyphen removal.","If your Cursor build stores a different ID format, verify it in state.vscdb before importing."],"tags":["validation","cursor","machine-id","uuid-format"],"backgroundTag":"invalid-token-format","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}