can1357/oh-my-pi · error

Share upload to ${base} failed: HTTP ${res.status}${detail ?

Error message

Share upload to ${base} failed: HTTP ${res.status}${detail ? ` (${detail})` : ""}

What it means

uploadToServer treats any non-2xx HTTP response from the share server as a failure. It includes the HTTP status and up to 200 chars of the response body (detail) in the error so the caller can see why the server rejected the upload (auth, size limit, rate limit, bad request).

Source

Thrown at packages/coding-agent/src/export/share.ts:679

		sealedBytes: forServer.sealed.byteLength,
	};
}

/** POST the sealed blob to the share server; returns the assigned id. */
async function uploadToServer(sealed: Uint8Array, base: string): Promise<string> {
	let res: Response;
	try {
		res = await fetch(base, {
			method: "POST",
			headers: { "Content-Type": "application/octet-stream" },
			body: sealed,
		});
	} catch (err) {
		throw new Error(`Share upload to ${base} failed: ${err instanceof Error ? err.message : String(err)}`);
	}
	if (!res.ok) {
		const detail = (await res.text().catch(() => "")).trim().slice(0, 200);
		throw new Error(`Share upload to ${base} failed: HTTP ${res.status}${detail ? ` (${detail})` : ""}`);
	}
	const body = (await res.json().catch(() => null)) as { id?: unknown } | null;
	const id = body && typeof body.id === "string" ? body.id : "";
	if (!/^[A-Za-z0-9_-]{10,64}$/.test(id)) {
		throw new Error(`Share upload to ${base} failed: server returned no usable id`);
	}
	return id;
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Read the HTTP status and detail in the message: 413 → session too large (trim content or raise server body limit); 401/403 → fix credentials; 429 → wait and retry; 5xx → check server logs.
  2. If 413: reduce session size (same remedies as 'session too large') or increase the server/proxy body-size limit (e.g. client_max_body_size).
  3. If 401/403: re-authenticate or update the share token in config/env.
  4. If 429: back off and retry later.
  5. If 5xx: retry once, then inspect the share server deployment.

Example fix

// before
await share.forServer(session); // fails: HTTP 413 (payload too large)
// after
// raise nginx limit on the share server: client_max_body_size 25m;
await share.forServer(session);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const id = await uploadToServer(base, sealed);
} catch (err) {
  const msg = err instanceof Error ? err.message : String(err);
  const m = msg.match(/HTTP (\d+)/);
  if (m) {
    const status = Number(m[1]);
    if (status === 413) { /* trim session or raise server body limit */ }
    else if (status === 401 || status === 403) { /* refresh auth */ }
    else if (status === 429) { /* back off and retry */ }
  } else throw err;
}

Prevention

When it happens

Trigger: The POST to the share server completed but returned e.g. 413 (payload too large), 401/403 (auth), 429 (rate limited), or 500; the server's response body text is appended as detail.

Common situations: Session exceeding the server's configured max body size; missing or expired share auth token; server rate-limiting frequent shares; reverse proxy (nginx/Cloudflare) rejecting large bodies; share server bug returning 5xx.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/40411e8ee1c34778. Report an issue: GitHub.