gitbutlerapp/gitbutler · error
The host rejected the request.
Error message
The host rejected the request.
What it means
handleAction sends a chat 'explain'/'review' request to the MCP host via app.sendMessage and throws a generic 'The host rejected the request.' when the returned result.isError is set. Unlike tool errors, the host's reason is not surfaced — the fixed message hides the underlying rejection cause.
Solutions
- Inspect the host/agent logs for the actual rejection reason — the thrown message is generic by design.
- Include textFromToolResult(result) (or the result's error content) in the thrown message to surface the real cause.
- Confirm the host session has an agent/model configured and is connected.
- Retry the send after the agent session is idle; verify the message content matches the host's expected schema.
- Disable or hide the Explain/Review actions when the host does not support chat.
Example fix
// before
if (result.isError) throw new Error("The host rejected the request.");
// after
if (result.isError) {
const reason = result.content?.map((c) => c.text ?? "").join("\n").trim();
throw new Error(reason || "The host rejected the request.");
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!app.isConnected?.()) { setDetailError("Agent host is not connected."); return; }
if (!chatSupported) { setDetailError("Chat is not available in this host."); return; } Type guard
function isSendOk(result: unknown): result is { isError: false } {
return typeof result === "object" && result !== null && (result as any).isError !== true;
} Try / catch
try {
const result = await app.sendMessage({ role: "user", content: [{ type: "text", text: request }] });
if (result.isError) throw new Error(extractHostReason(result) ?? "The host rejected the request.");
} catch (caught) {
setDetailError(caught instanceof Error ? caught.message : "Could not start the agent request.");
} finally {
setPendingAction(null);
} Prevention
- Feature-detect chat/agent support before showing Explain/Review buttons.
- Never throw away the host's error details — include them in the thrown message.
- Check the agent session state (idle/connected) before sending.
- Keep the message payload aligned with the host's expected content schema.
When it happens
Trigger: The host returns isError for the chat message: no agent/model session available, the host disallows chat for this app state, invalid message content shape, or host-side agent failure.
Common situations: Operating the app in a host that has no agent/LLM configured; sending a prompt while the agent session is busy or terminated; the host denying message sends for permissions/quota reasons.
Related errors
- At least one review number is required
- is not open and cannot be marked ready
- Marking reviews ready is not supported for
- MCP root is not a file URI
- No repository was provided and this MCP client does not…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/bd9695d30d9c64a6.
Report an issue: GitHub.
Appendix: source
Thrown at packages/but-mcp-app/src/WorkspaceApp.tsx:792
await app.updateModelContext(selectionContext(view, selection));
} catch {
// The message below carries the same repository and selection context.
}
}
const identifier = selectionIdentifier(selection);
const subject =
selection.kind === "commit"
? `commit ${identifier}`
: `branch ${identifier} against its configured target`;
const request =
action === "explain"
? `Explain ${subject} in repository ${view.repository.path}. Describe its intent and the important changes.`
: `Review ${subject} in repository ${view.repository.path} for correctness, regressions, and missing tests.`;
const result = await app.sendMessage({
role: "user",
content: [{ type: "text", text: request }],
});
if (result.isError) throw new Error("The host rejected the request.");
} catch (caught) {
setDetailError(
caught instanceof Error ? caught.message : "Could not start the agent request.",
);
} finally {
setPendingAction(null);
}
}
function clearSelection() {
detailRequest.current += 1;
setSelection(null);
setDetail(null);
setDetailError(null);
setDetailLoading(false);
setCopied(null);
setPendingAction(null);
if (canUpdateContext) {View on GitHub (pinned to 58e5313667)