Budibase/budibase · error · HTTPError
chatConversationId in body does not match path
Error message
chatConversationId in body does not match path
What it means
Analogous to the agentId check: if the path's chatConversationId is a concrete id (not 'new') and the body's chat._id refers to a different conversation, the request is rejected with HTTP 400 to prevent writing messages into the wrong conversation.
Source
Thrown at packages/server/src/api/controllers/ai/chatConversations.ts:359
}
const applyChatStreamPathParams = (
chat: ChatAgentRequest,
params: UserCtx<ChatAgentRequest, void>["params"]
) => {
const agentId = params?.agentId
if (agentId && chat.agentId && chat.agentId !== agentId) {
throw new HTTPError("agentId in body does not match path", 400)
}
const chatConversationId = params?.chatConversationId
if (
chatConversationId &&
chatConversationId !== "new" &&
chat._id &&
chat._id !== chatConversationId
) {
throw new HTTPError("chatConversationId in body does not match path", 400)
}
if (agentId) {
chat.agentId = agentId
}
if (chatConversationId && chatConversationId !== "new") {
chat._id = chatConversationId
}
}
const resolveChatStreamRequest = async (
ctx: UserCtx<ChatAgentRequest, void>
): Promise<ResolvedChatStreamRequest> => {
const chat = ctx.request.body
const userId = getGlobalUserId(ctx)
applyChatStreamPathParams(chat, ctx.params)
const workspaceId = context.getWorkspaceId()View on GitHub (pinned to a81a902e9a)
Solutions
- Set body._id to the same conversation id as in the path
- Use 'new' in the path when starting a conversation and let the server assign the id
- Clear the cached body's _id before reusing it for another conversation
Example fix
// before
POST /api/ai/chat/agent_1/conv_AAA/stream
{ "_id": "conv_BBB", ... }
// after
POST /api/ai/chat/agent_1/conv_AAA/stream
{ "_id": "conv_AAA", ... } Defensive patterns
Strategy: validation
Validate before calling
if (body._id && pathConversationId !== "new" && body._id !== pathConversationId) {
throw new Error("body._id must match the path chatConversationId")
} Try / catch
try {
await streamChat(agentId, conversationId, body)
} catch (e) {
if (e.status === 400 && String(e.message).includes("chatConversationId in body does not match path")) {
// reset body._id or start a new conversation with "new"
}
} Prevention
- Reset conversation state when switching conversations in the UI
- Use "new" for fresh conversations and adopt the server-assigned id
- Never mutate a stale body's conversation id manually
When it happens
Trigger: POST to a chat stream path containing a conversation id while body._id is a different conversation id, e.g. resuming a stale body against a new conversation URL.
Common situations: Client switching conversations but keeping an old body; retries after a conversation was created/deleted so ids diverge; copy-pasted request payloads.
Related errors
- agentId in body does not match path
- Invalid bookmark query
- Invalid limit query
- Limit query must be between 1 and 100
- Invalid ${queryName} query
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/5a286a25d497e443.
Report an issue: GitHub.