BigPizzaV3/CodexPlusPlus · error
新建会话失败:app-server 未返回 thread id
Error message
新建会话失败:app-server 未返回 thread id
What it means
After sending thread/start, the page defensively unwraps the JSON-RPC result through several shapes (result.thread.id, result.threadId, result.id). If none of them yields a thread id, the new session cannot be tracked, so sendMessage throws this error instead of continuing with an undefined threadId.
Solutions
- Log the full thread/start result and update the unwrap chain to match the current app-server schema.
- Update the relay page and app-server to matching versions.
- Check whether thread/start actually returned a JSON-RPC error and surface it instead of the generic message.
- Retry thread/start once; if it still returns no id, show the raw response to the user for diagnosis.
Example fix
// before
threadId = thread?.id || result?.threadId || result?.id;
// after
threadId = thread?.id || result?.threadId || result?.id;
if (!threadId && result?.error) throw new Error(`新建会话失败:${result.error.message ?? JSON.stringify(result.error)}`); Defensive patterns
Strategy: try-catch
Validate before calling
const result = await rpc("thread/start", opts); const threadId = result?.thread?.id || result?.threadId || result?.id; if (!threadId) throw new Error(`thread/start 响应异常:${JSON.stringify(result).slice(0, 200)}`); Type guard
function extractThreadId(result) { const t = result?.thread ?? result?.data ?? result; return (typeof t?.id === "string" && t.id) || (typeof result?.threadId === "string" && result.threadId) || null; } Try / catch
try { const id = extractThreadId(await rpc("thread/start", opts)); if (!id) throw new Error("no thread id"); } catch (e) { setStatus(`新建会话失败:${e.message}`, true); } Prevention
- Log the raw thread/start response once when upgrading app-server versions.
- Surface result.error from JSON-RPC replies instead of a generic message.
- Keep relay page and app-server versions matched.
When it happens
Trigger: rpc("thread/start", ...) resolves but the response lacks id in every expected location: app-server returned an error-shaped result, an older/newer app-server version changed the reply schema, or the reply was an empty object due to a forwarding bug.
Common situations: Codex app-server updated with a changed thread/start response schema; relay forwarded a JSON-RPC error object as if it were a result; mismatched relay/app-server versions; cwd rejected silently server-side.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/2c88026bcfa76912.
Report an issue: GitHub.
Appendix: source
Thrown at apps/codex-plus-mobile-relay/src/main.rs:1257
return await rpc("turn/start", { threadId, clientUserMessageId: `codex-plus-mobile-${Date.now()}`, input: [{ type: "text", text }] });
}
$("connect").onclick = connect;
$("filter").oninput = (event) => { state.filter = event.target.value; renderSessions(); };
$("back").onclick = () => { detailPane.classList.add("hidden"); sessionsPane.classList.remove("hidden"); };
$("composer").onsubmit = async (event) => {
event.preventDefault();
const input = $("messageInput");
const text = input.value.trim();
if (!text) return;
input.value = "";
let threadId = state.selectedId;
let isNew = false;
try {
if (!threadId) {
const result = await rpc("thread/start", state.selectedCwd ? { cwd: state.selectedCwd } : {});
const thread = result?.thread || result?.data || result;
threadId = thread?.id || result?.threadId || result?.id;
if (!threadId) throw new Error("新建会话失败:app-server 未返回 thread id");
state.selectedId = threadId;
isNew = true;
}
rememberPendingMessage(threadId, text);
appendMessageNode("用户", text, true);
setStatus("正在思考...");
pollThread(threadId);
sendMessage(threadId, text, isNew)
.then(() => setStatus("已发送,正在同步回复..."))
.catch((error) => {
forgetPendingMessage(threadId, text);
setStatus(error.message, true);
});
} catch (error) {
forgetPendingMessage(threadId, text);
setStatus(error.message, true);
}
};View on GitHub (pinned to b1ed92e5e4)