{"record":{"id":"0ce8b035eaf44ae2","repo":"alyssaxuu/screenity","slug":"drive-folder-search-failed-searchres-status","errorCode":null,"errorMessage":"Drive folder search failed: ${searchRes.status} ${text}","messagePattern":"Drive folder search failed: (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/Background/drive/handleSaveToDrive.js","lineNumber":24,"sourceCode":"\nconst findOrCreateScreenityFolder = async (token) => {\n  const headers = new Headers({\n    Authorization: `Bearer ${token}`,\n    \"Content-Type\": \"application/json\",\n  });\n\n  const query = encodeURIComponent(\n    `name='Screenity' and mimeType='application/vnd.google-apps.folder' and trashed=false`\n  );\n\n  const searchRes = await fetch(\n    `https://www.googleapis.com/drive/v3/files?q=${query}&fields=files(id,name)`,\n    { headers }\n  );\n\n  if (!searchRes.ok) {\n    const text = await searchRes.text().catch(() => \"\");\n    throw new Error(\n      `Drive folder search failed: ${searchRes.status} ${text}`\n    );\n  }\n\n  const result = await searchRes.json();\n  if (result.files?.length) return result.files[0].id;\n\n  const createRes = await fetch(`https://www.googleapis.com/drive/v3/files`, {\n    method: \"POST\",\n    headers,\n    body: JSON.stringify({\n      name: \"Screenity\",\n      mimeType: \"application/vnd.google-apps.folder\",\n    }),\n  });\n\n  if (!createRes.ok) {\n    const text = await createRes.text().catch(() => \"\");","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/Background/drive/handleSaveToDrive.js#L6-L42","documentation":"The Drive files.list query looking for the 'Screenity' folder returned a non-OK HTTP response. Thrown in findOrCreateScreenityFolder when searchRes.ok is false — usually an expired/insufficient OAuth token, quota, or transient API error — so the upload cannot locate or create its destination folder.","triggerScenarios":"Thrown at src/pages/Background/drive/handleSaveToDrive.js:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Refresh the OAuth token on 401/403 and ensure the drive/drive.file scope is granted","Parse the Drive JSON error in `text` for the exact reason (rateLimitExceeded, insufficientPermissions)","Back off and retry on 429/5xx per Drive API error guidance","Verify the query encoding and that the Drive API is enabled for the project"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}