gildas-lormeau/SingleFile · error · Error

path_not_found

path_not_found

Error message

path_not_found

What it means

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.

Source

Thrown at src/lib/gdrive/gdrive.js:487

		getResponse(httpResponse);
	}
}

async function getJSON(httpResponse) {
	httpResponse = getResponse(httpResponse);
	const response = await httpResponse.json();
	if (response.error) {
		throw new Error(response.error);
	} else {
		return response;
	}
}

function getResponse(httpResponse) {
	if (httpResponse.status == 200) {
		return httpResponse;
	} else if (httpResponse.status == 404) {
		throw new Error("path_not_found");
	} else if (httpResponse.status == 401) {
		throw new Error("invalid_token");
	} else {
		throw new Error("unknown_error (" + httpResponse.status + ")");
	}
}

View on GitHub (pinned to 517fb7c5cf)

Solutions

  1. Verify the file/folder ID exists by listing the parent folder via the library's list/getFolder functions.
  2. Confirm the authenticated account has at least read access to the resource (share it or re-authenticate as the owner).
  3. Trim whitespace and re-copy the ID from the Drive URL (the part after /d/).
  4. Implement creation fallback: if the path/folder is missing, create it before uploading.

Example fix

// before
const file = await gdrive.readFile(fileId); // 404 -> path_not_found
// after
let file;
try {
  file = await gdrive.readFile(fileId);
} catch (e) {
  if (e.message === "path_not_found") {
    file = await gdrive.createFile(defaultContent);
  } else throw e;
}
Defensive patterns

Strategy: validation

Validate before calling

function isValidDriveId(id) {
  return typeof id === "string" && /^[A-Za-z0-9_-]{10,}$/.test(id.trim());
}
// verify existence first (via folder listing) before read/write
if (!isValidDriveId(fileId)) throw new Error("bad file id before API call");

Try / catch

try { await gdrive.readFile(fileId); }
catch (e) {
  if (e.message === "path_not_found") { return createFallbackResource(); }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "path not found", "No such file or directory", "Directory does not exist": when a library can't resolve the path you gave it — this error's family across 53 libraries.

Related errors


AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01). Data as JSON: /api/errors/8a4a28147a98845c. Report an issue: GitHub.