{"record":{"id":"8a4a28147a98845c","repo":"gildas-lormeau/SingleFile","slug":"path-not-found","errorCode":"path_not_found","errorMessage":"path_not_found","messagePattern":"path_not_found","errorType":"error_code","errorClass":"Error","httpStatus":404,"severity":"error","filePath":"src/lib/gdrive/gdrive.js","lineNumber":487,"sourceCode":"\t\tgetResponse(httpResponse);\n\t}\n}\n\nasync function getJSON(httpResponse) {\n\thttpResponse = getResponse(httpResponse);\n\tconst response = await httpResponse.json();\n\tif (response.error) {\n\t\tthrow new Error(response.error);\n\t} else {\n\t\treturn response;\n\t}\n}\n\nfunction getResponse(httpResponse) {\n\tif (httpResponse.status == 200) {\n\t\treturn httpResponse;\n\t} else if (httpResponse.status == 404) {\n\t\tthrow new Error(\"path_not_found\");\n\t} else if (httpResponse.status == 401) {\n\t\tthrow new Error(\"invalid_token\");\n\t} else {\n\t\tthrow new Error(\"unknown_error (\" + httpResponse.status + \")\");\n\t}\n}\n","sourceCodeStart":469,"sourceCodeEnd":494,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/lib/gdrive/gdrive.js#L469-L494","documentation":"getResponse is the central HTTP status gate for the gdrive library. A 404 status is converted to \"path_not_found\", meaning the requested Drive resource (file or folder ID) does not exist or the app cannot see it. All HTTP responses must pass through this check, so any 404 from list/read/upload-metadata calls surfaces as this error.","triggerScenarios":"Reading/uploading to a file or folder ID that was deleted; mistyped or truncated file/folder ID; file not shared with the authenticated account (Drive returns 404 rather than 403 for inaccessible files in some cases); using a resource from another Drive account/domain without permission.","commonSituations":"Hardcoded file IDs that break after a user moves/deletes the file; storing IDs per-user and replaying them under a different account; shared-drive files not shared with the service account; trailing whitespace in IDs from config files.","solutions":["Verify the file/folder ID exists by listing the parent folder via the library's list/getFolder functions.","Confirm the authenticated account has at least read access to the resource (share it or re-authenticate as the owner).","Trim whitespace and re-copy the ID from the Drive URL (the part after /d/).","Implement creation fallback: if the path/folder is missing, create it before uploading."],"exampleFix":"// before\nconst file = await gdrive.readFile(fileId); // 404 -> path_not_found\n// after\nlet file;\ntry {\n  file = await gdrive.readFile(fileId);\n} catch (e) {\n  if (e.message === \"path_not_found\") {\n    file = await gdrive.createFile(defaultContent);\n  } else throw e;\n}","handlingStrategy":"validation","validationCode":"function isValidDriveId(id) {\n  return typeof id === \"string\" && /^[A-Za-z0-9_-]{10,}$/.test(id.trim());\n}\n// verify existence first (via folder listing) before read/write\nif (!isValidDriveId(fileId)) throw new Error(\"bad file id before API call\");","typeGuard":null,"tryCatchPattern":"try { await gdrive.readFile(fileId); }\ncatch (e) {\n  if (e.message === \"path_not_found\") { return createFallbackResource(); }\n  throw e;\n}","preventionTips":["Store Drive IDs per-account and re-validate after account switches","Trim IDs read from config/env files","Re-check resource existence after user moves/deletes files","Share required files with the service account"],"tags":["http-404","not-found","gdrive","google-api"],"backgroundTag":"resource-not-found-404","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}