{"record":{"id":"dc32d7fc26f1546d","repo":"can1357/oh-my-pi","slug":"gemini-files-api-delete-request-failed","errorCode":null,"errorMessage":"Gemini Files API delete request failed","messagePattern":"Gemini Files API delete request failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/provider-files-gemini.ts","lineNumber":167,"sourceCode":"\t\t\t\t\theaders: { \"x-goog-api-key\": credential },\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tasync delete(handle: ProviderFileHandle): Promise<void> {\n\t\t\tif (handle.provider !== \"google\")\n\t\t\t\tthrow new Error(\"Gemini Files API cannot delete a handle from another provider\");\n\t\t\tconst name = handle.id;\n\t\t\tif (typeof name !== \"string\" || !/^files\\/[^/]+$/.test(name)) {\n\t\t\t\tthrow new Error(\"Gemini Files API delete requires a valid file name\");\n\t\t\t}\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await fetchImpl(`${GEMINI_FILES_RESOURCE_URL}/${name}`, {\n\t\t\t\t\tmethod: \"DELETE\",\n\t\t\t\t\theaders: { \"x-goog-api-key\": credential },\n\t\t\t\t});\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\"Gemini Files API delete request failed\");\n\t\t\t}\n\t\t\tif (!response.ok) throw new Error(`Gemini Files API delete failed with HTTP ${response.status}`);\n\t\t},\n\t};\n}\n","sourceCodeStart":149,"sourceCodeEnd":173,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/provider-files-gemini.ts#L149-L173","documentation":"Thrown by the Gemini provider's delete() when the fetch call itself throws — i.e. the DELETE request to the Gemini Files API never completed at the transport level (the library replaces the original error with this generic message). This is distinct from an HTTP error status (744), which means the request did complete.","triggerScenarios":"Calling delete() when fetch throws: DNS failure, connection refused/reset, TLS errors, request aborted via signal, offline network, or a custom fetchImpl that rejects.","commonSituations":"No internet or firewall blocking generativelanguage.googleapis.com; corporate proxy requiring auth; DNS misconfiguration; deleting during process shutdown while the network stack is torn down; a custom fetchImpl with a timeout that fires.","solutions":["Check network connectivity and that generativelanguage.googleapis.com is reachable (curl the endpoint).","Inspect proxy/firewall/VPN settings; configure HTTPS_PROXY if the environment requires it.","Retry the delete with exponential backoff — deletes are idempotent, so a dropped request can safely be re-sent.","If using a custom fetchImpl, log or wrap the underlying error to see the real cause (this library swallows it).","Verify the request is not being aborted by an upstream AbortSignal that fires too early."],"exampleFix":"// before: fire-and-forget delete that loses the real cause\nawait geminiClient.delete(handle);\n// after: tolerate transient transport failures, delete is idempotent\ntry {\n  await geminiClient.delete(handle);\n} catch (err) {\n  if (!/delete request failed/.test(err.message)) throw err;\n  await Bun.sleep(1000);\n  await geminiClient.delete(handle).catch(() => {}); // best-effort cleanup\n}","handlingStrategy":"retry","validationCode":"// reachability pre-check\nconst res = await fetch(\"https://generativelanguage.googleapis.com\").catch(() => null);\nif (!res) throw new Error(\"Gemini endpoint unreachable; skip delete\");","typeGuard":null,"tryCatchPattern":"try {\n  await geminiClient.delete(handle);\n} catch (err) {\n  if (typeof err?.message === \"string\" && err.message.includes(\"delete request failed\")) {\n    // transport-level failure: safe to retry (delete is idempotent)\n    await Bun.sleep(1000);\n    await geminiClient.delete(handle).catch(() => {}); // best-effort cleanup\n  } else throw err;\n}","preventionTips":["Retry transport failures — DELETE is idempotent","Configure HTTPS_PROXY in locked-down networks","Avoid deleting during shutdown windows when the network stack may be gone","Wrap bulk cleanup so one network blip doesn't abort the batch"],"tags":["network","fetch","gemini","file-delete","connectivity"],"backgroundTag":"fetch-network-failure","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}