can1357/oh-my-pi · error
OpenAI Files API upload request failed
Error message
OpenAI Files API upload request failed
What it means
The OpenAI Files API client wraps the low-level fetch call for POST https://api.openai.com/v1/files and deliberately swallows the original error, rethrowing this generic message. It means the HTTP request itself never completed — a network-level failure (DNS, TLS, connection reset) or an AbortSignal-triggered abort — not an HTTP error status from OpenAI. The client discards the underlying cause, so you only see this opaque message.
Source
Thrown at packages/coding-agent/src/blob-broker/provider-files-openai.ts:98
async upload(uploadRequest: ProviderFileUploadRequest): Promise<ProviderFileHandle> {
const form = new FormData();
form.append("purpose", "vision");
form.append(
"file",
new Blob([uploadRequest.bytes], { type: uploadRequest.mimeType }),
fileName(uploadRequest),
);
let response: Response;
try {
response = await request(OPENAI_FILES_URL, {
method: "POST",
headers: { Authorization: authorization },
body: form,
signal: uploadRequest.signal,
});
} catch {
throw new Error("OpenAI Files API upload request failed");
}
if (!response.ok) {
throw new Error(`OpenAI Files API upload failed with HTTP ${response.status}`);
}
let payload: unknown;
try {
payload = await response.json();
} catch {
throw new Error("OpenAI Files API returned an invalid upload response");
}
const file = parseOpenAIFileResponse(payload);
if (file.status === "error") throw new Error("OpenAI Files API reported that the upload failed");
const deleteUrl = `${OPENAI_FILES_URL}/${encodeURIComponent(file.id)}`;
return {
provider: "openai",
id: file.id,View on GitHub (pinned to 9690622007)
Solutions
- Check basic connectivity: curl -sS https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY" and verify it returns 200
- Inspect the abort path: confirm nothing calls AbortController.abort() (timeout, user cancel) before the upload finishes
- Check proxy env vars (HTTPS_PROXY/HTTPS_PROXY) are correct and reachable; OpenAI blocks some proxy IPs
- Retry with exponential backoff — transient network resets are common on large uploads
Example fix
// before: opaque error hides the cause
} catch {
throw new Error("OpenAI Files API upload request failed");
}
// after (caller side): capture and surface the cause with retry
try {
await client.upload({ bytes, mimeType, filename, signal });
} catch (err) {
if (signal.aborted) throw err;
logger.warn("openai file upload network failure; retrying", { err });
await backoffRetry(() => client.upload({ bytes, mimeType, filename, signal }));
} Defensive patterns
Strategy: retry
Validate before calling
// pre-flight connectivity probe
const ctrl = new AbortController();
const ok = await fetch("https://api.openai.com/v1/models", {
headers: { Authorization: `Bearer ${key}` },
signal: ctrl.signal,
}).then((r) => r.ok).catch(() => false);
if (!ok) throw new Error("api.openai.com unreachable before upload"); Type guard
function isAbortError(err: unknown): boolean {
return err instanceof Error && err.name === "AbortError";
} Try / catch
try {
await client.upload(req);
} catch (err) {
if (isAbortError(err) || req.signal.aborted) throw err; // don't retry cancels
logger.warn("openai upload network failure", { err });
await withBackoff(() => client.upload(req), { retries: 3 });
} Prevention
- Probe api.openai.com reachability before large/batch uploads
- Use AbortSignal.timeout() so hung requests fail fast and predictably
- Retry idempotent uploads with exponential backoff
- Check proxy env vars (HTTPS_PROXY) when running in corporate networks
When it happens
Trigger: Calling client.upload() when the machine is offline, DNS for api.openai.com fails, TLS is intercepted/broken, a proxy rejects the connection, or the AbortSignal passed in uploadRequest.signal fires mid-request.
Common situations: Corporate proxy/firewall blocking api.openai.com; flaky Wi-Fi or VPN drops; request aborted because the user cancelled or a timeout fired; misconfigured HTTPS_PROXY; IPv6/DNS issues in containers.
Related errors
- OpenAI Files API delete request failed
- V2 remote compaction failed (${response.status} ${response.s
- AnthropicConnectionError
- AnthropicConnectionTimeoutError
- xAI device-code request failed: ${error instanceof Error ? e
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/8d95d2b67915edb6.
Report an issue: GitHub.