BigPizzaV3/CodexPlusPlus · error · Error
创建失败
Error message
创建失败
What it means
Thrown by the share-site's setupComposer after POSTing the encrypted payload to the share creation API. When the HTTP response is not ok, the server-provided data.error is used as the message; otherwise the generic "创建失败" ("creation failed") is thrown. The share URL and delete token are only stored after this check passes.
Solutions
- Check the Network tab for the failing request's status and response body — the data.error field contains the server's reason.
- Verify the ttl input (#ttl) holds a valid positive number; Number("") is 0 and Number of garbage is NaN, both likely rejected server-side.
- Confirm the payload size is within the server's body limit; re-encrypt or trim the shared content if 413.
- Retry later for 5xx errors, and check the share service's health/logs server-side.
Example fix
// before: NaN/0 ttl submitted silently
ttl: Number(document.querySelector("#ttl").value),
// after: validate ttl before submitting
const ttl = Number(document.querySelector("#ttl").value);
if (!Number.isInteger(ttl) || ttl <= 0) {
alert("请输入有效的 TTL(正整数秒)");
return;
}
// ... body: JSON.stringify({ encrypted: encrypted.payload, ttl }) Defensive patterns
Strategy: validation
Validate before calling
const ttl = Number(document.querySelector("#ttl").value);
if (!Number.isFinite(ttl) || ttl <= 0) throw new Error("请输入有效的 TTL");
if (!encrypted?.payload) throw new Error("缺少加密数据"); Type guard
function isShareResponse(v) {
return v != null && typeof v === "object" && typeof v.id === "string" && typeof v.deleteToken === "string";
} Try / catch
try {
const response = await fetch("/api/shares", { method: "POST", body: JSON.stringify(payload) });
const data = await response.json().catch(() => ({}));
if (!response.ok || !isShareResponse(data)) {
throw new Error(data.error || `创建失败(HTTP ${response.status})`);
}
} catch (e) {
statusEl.textContent = e.message;
} Prevention
- Validate ttl and encrypted payload client-side before submitting.
- Show the server's data.error verbatim to help users diagnose 4xx causes.
- Disable the submit button while the request is in flight to avoid duplicate/aborted requests.
- Monitor share API uptime and surface a clear 'service unavailable' state for 5xx.
When it happens
Trigger: Submitting the share composer form when the API returns 4xx/5xx (invalid payload, ttl out of range, payload too large, server error), or a 2xx body without the expected id/fields that still trips response.ok checks via data.error being absent.
Common situations: Share service backend is down or misconfigured; ttl value invalid (e.g. empty or non-numeric input in #ttl after Number() coercion yields NaN); encrypted payload exceeds server body limit; server rejects request due to rate limits or missing CSRF/auth headers.
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 BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/ea2daaaf2342f4a5.
Report an issue: GitHub.
Appendix: source
Thrown at services/share-site/app.js:46
form.addEventListener("submit", async (event) => {
event.preventDefault();
setNotice("");
submit.disabled = true;
submit.textContent = "正在加密...";
try {
const encrypted = await encryptText(content.value);
const response = await fetch("/api/shares", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
encrypted: encrypted.payload,
ttl: Number(document.querySelector("#ttl").value),
}),
});
const data = await response.json();
if (!response.ok) throw new Error(data.error || "创建失败");
const url = new URL(location.origin);
url.searchParams.set("s", data.id);
url.hash = `k=${encrypted.key}`;
shareUrl.value = url.toString();
localStorage.setItem(`codexpp-share-delete:${data.id}`, data.deleteToken);
result.dataset.shareId = data.id;
result.hidden = false;
setNotice("链接已创建。正文和密钥均未以明文发送。", "success");
} catch (error) {
setNotice(error instanceof Error ? error.message : "创建失败,请稍后重试。", "error");
} finally {
submit.disabled = false;
submit.textContent = "加密并创建链接";
}
});
document.querySelector("[data-copy]").addEventListener("click", async () => {View on GitHub (pinned to b1ed92e5e4)