BigPizzaV3/CodexPlusPlus · error

创建分享失败

Error message

创建分享失败

What it means

Thrown in the share-creation flow when the POST /share/create call returns a response without an id but with status other than "failed" — i.e. the backend responded in an unexpected, non-error-looking way but produced no share id. The message "创建分享失败" ("share creation failed") signals that no usable share identifier came back, so the share URL cannot be constructed.

Solutions

  1. Inspect the actual /share/create response body (result.message) to see the backend-reported reason.
  2. Check backend service health/availability for the share service and retry the share.
  3. Update the client so its expected response shape (result.id) matches the deployed share API contract.
  4. Verify the request payload (ttl, encrypted blob) passes backend validation — oversized payloads may silently fail to produce an id.

Example fix

// before: silently swallow and fall back even on real errors
try {
  result = await postJson("/share/create", payload);
  if (!result?.id) throw new Error(result?.message || "创建分享失败");
} catch (_) { result = null; }
// after: log the backend message before falling back
try {
  result = await postJson("/share/create", payload);
  if (!result?.id) {
    console.warn("share/create failed:", result?.message);
    if (result?.status !== "failed") throw new Error(result?.message || "创建分享失败");
  }
} catch (e) { console.warn(e); result = null; }
Defensive patterns

Strategy: try-catch

Validate before calling

if (!payload?.encrypted || !(payload.ttl > 0)) throw new Error("分享参数无效,已取消创建");

Type guard

function hasShareId(v) {
  return v != null && typeof v === "object" && typeof v.id === "string" && v.id.length > 0;
}

Try / catch

try {
  result = await postJson("/share/create", payload);
  if (!hasShareId(result) && result?.status !== "failed") {
    console.warn("share/create 异常响应:", result);
    throw new Error(result?.message || "创建分享失败");
  }
} catch (e) {
  console.warn("bridge 创建失败,回退直连:", e);
  result = null;
}

Prevention

When it happens

Trigger: Calling the share action when /share/create returns an object with no id field and status !== "failed"; or the endpoint returns its own message which replaces the default text. Note the code swallows thrown errors into result = null and falls back to the direct HTTP path, so this specific throw only fires on a well-formed JSON response lacking id.

Common situations: Backend deployed with a changed response schema (id renamed or nested); rate limiting or quota responses that return 200 with a body lacking id; proxy/gateway injecting an HTML or alternate JSON body without id.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/823930292ff1250a. Report an issue: GitHub.

Appendix: source

Thrown at assets/inject/renderer-inject.js:7597

      let shareDocument = session;
      const nativeSession = await postJson("/session/export", {
        session_id: ref.session_id,
        title: session.title,
      });
      if (nativeSession?.status !== "ok" || nativeSession.kind !== "codex-rollout" || typeof nativeSession.content !== "string") {
        throw new Error(nativeSession?.message || "无法读取完整 Codex 会话文件");
      }
      shareDocument = { ...nativeSession, title: session.title };
      const encrypted = await encryptSessionShare(JSON.stringify(shareDocument));
      const payload = { ttl: 604800, encrypted: encrypted.encrypted };
      let result;
      let baseUrl = codexPlusShareBaseUrl;
      try {
        result = await postJson("/share/create", payload);
        if (result?.id) {
          baseUrl = codexPlusShareBaseUrl;
        } else if (result?.status !== "failed") {
          throw new Error(result?.message || "创建分享失败");
        }
      } catch (_) {
        result = null;
      }
      if (!result?.id) {
        let response;
        try {
          response = await fetch(`${baseUrl}/api/shares`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) });
        } catch (_) {
          baseUrl = codexPlusShareFallbackBaseUrl;
          response = await fetch(`${baseUrl}/api/shares`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) });
        }
        result = await response.json().catch(() => ({}));
        if (!response.ok || !result.id) throw new Error(result.error || `创建分享失败(HTTP ${response.status})`);
      }
      const shareUrl = `${baseUrl}/?s=${encodeURIComponent(result.id)}#k=${encrypted.key}`;
      try {
        await navigator.clipboard.writeText(shareUrl);

View on GitHub (pinned to b1ed92e5e4)