koodo-reader/koodo-reader · error · Error
Failed to get folder info: ${response.statusText}
Error message
Failed to get folder info: ${response.statusText} What it means
GoogleDriveService.getFolderInfo() queries Drive (files list filtered by folder name/mimeType) to locate or describe a folder, and throws this error on any non-ok response. Like the other Drive methods, failures are usually auth-, permission-, or rate-limit-related rather than logic errors.
Source
Thrown at src/utils/file/googlePicker.ts:135
throw new Error(`Failed to get file metadata: ${response.statusText}`);
}
return await response.json();
}
// 获取文件夹信息
async getFolderInfo(folderId: string): Promise<any> {
const response = await fetch(
`https://www.googleapis.com/drive/v3/files/${folderId}?fields=id,name,mimeType`,
{
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
}
);
if (!response.ok) {
throw new Error(`Failed to get folder info: ${response.statusText}`);
}
return await response.json();
}
}
View on GitHub (pinned to 7d40df41e0)
Solutions
- On 401/403, refresh the token or re-run OAuth with the correct scopes (drive metadata access) and retry
- Validate the query string (name/mimeType filters) — 400 indicates a malformed query
- Retry 429/5xx with exponential backoff and jitter
- Confirm the folder exists under the currently authenticated account before querying
Example fix
// before
if (!response.ok) {
throw new Error(`Failed to get folder info: ${response.statusText}`);
}
// after
if (!response.ok) {
if (response.status === 401) {
await this.refreshAccessToken();
return this.getFolderInfo(folderName);
}
if (response.status === 429) {
await new Promise((r) => setTimeout(r, 2000));
return this.getFolderInfo(folderName);
}
throw new Error(`Failed to get folder info: HTTP ${response.status}`);
} Defensive patterns
Strategy: retry
Validate before calling
if (!drive.accessToken) throw new Error("not authenticated");
if (!folderName || folderName.includes("'")) throw new Error("invalid folder name"); Type guard
function isDriveFolder(v: unknown): v is { id: string; name: string; mimeType: string } {
return !!v && typeof v === "object" && (v as any).mimeType === "application/vnd.google-apps.folder";
} Try / catch
try {
const info = await drive.getFolderInfo(name);
} catch (e) {
if (e.message.includes("Failed to get folder info")) {
await sleep(2000);
return drive.getFolderInfo(name); // backoff retry
} else throw e;
} Prevention
- Escape single quotes in Drive query strings to avoid 400s
- Refresh tokens on 401 before surfacing errors
- Throttle folder lookups to respect Drive per-minute quotas
- Verify the active Google account owns/see the folder
When it happens
Trigger: Calling getFolderInfo with an expired access token, when the authenticated account cannot see the folder (shared drive not in scope), malformed query parameters rejected with 400, or 429/5xx from Drive under rate limiting.
Common situations: First-time sync before scopes are granted, user switched Google accounts so the token belongs to an account without the folder, or bulk operations tripping Drive per-minute query quotas.
Related errors
- Failed to download file: ${response.statusText}
- Failed to get file metadata: ${response.statusText}
- HTTP ${response.status}: ${response.statusText}
- HTTP ${response.status}
- HTTP ${response.status}
AI-assisted analysis of koodo-reader/koodo-reader@7d40df41e0 (2026-08-29).
Data as JSON: /api/errors/da36e80a1522bd28.
Report an issue: GitHub.