gitbutlerapp/gitbutler · error
The updated review was missing from the response.
Error message
The updated review was missing from the response.
What it means
After a successful (non-error) mark_review_ready response, markReady parses the structured review view and expects at least one review in updatedView.reviews. If the structured content is absent or contains an empty reviews array, this invariant error is thrown, meaning the tool succeeded but returned an unusable payload.
Solutions
- Log the raw result content to confirm what structured data the tool actually returned.
- Re-fetch the review list to get the current view instead of relying on the mark-ready response.
- Check that the host and the but-mcp-app agree on the tool response schema (version alignment).
- Treat the local review state as unchanged and surface a retry prompt rather than crashing the action.
- If persistent, report an internal-invariant bug with the raw payload.
Example fix
// before
const updatedReview = updatedView?.reviews[0];
if (!updatedReview) throw new Error("The updated review was missing from the response.");
// after
const updatedReview = updatedView?.reviews[0];
if (!updatedReview) { await refreshReviews(); return; } Defensive patterns
Strategy: validation
Validate before calling
const parsed = reviewViewFromToolResult(result);
if (parsed === null || !Array.isArray(parsed.reviews) || parsed.reviews.length === 0) {
throw new Error("Tool returned no reviews: " + textFromToolResult(result).slice(0, 200));
} Type guard
function hasReview(view: unknown): view is { reviews: [Review, ...unknown[]] } {
return typeof view === "object" && view !== null &&
Array.isArray((view as any).reviews) && (view as any).reviews.length > 0;
} Try / catch
catch (actionCause) {
if (isMissingReviewInvariant(actionCause)) {
await refreshReviews(); // recover by refetching instead of failing
} else {
setActionError(actionCause instanceof Error ? actionCause.message : "Could not mark the review ready.");
}
} Prevention
- Keep but-mcp-app and the host on matching versions so tool schemas agree.
- Log raw tool results at debug level to diagnose shape drift quickly.
- Never assume structuredContent exists on a successful tool result — parse and guard.
- Add a regression test for empty/absent reviews payloads.
When it happens
Trigger: reviewViewFromToolResult returns a view whose reviews array is empty or null — e.g. the tool returned only unstructured text content, or the host returned an empty/legacy payload shape.
Common situations: Version mismatch between the app and the host's tool schema (tool updated to return a different shape); a stale review was deleted server-side so the refreshed view no longer contains it; the tool silently degraded to a text-only response.
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
- The detail result was missing structured data.
- anchor is always present in the order at this point
- At least one review number is required
- Change to discard at
- commits cannot be moved to the merge base
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/aa9b4a5690b88639.
Report an issue: GitHub.
Appendix: source
Thrown at packages/but-mcp-app/src/ReviewApp.tsx:404
const connectedApp = app;
const currentView = view;
const canCallTools = connectedApp.getHostCapabilities()?.serverTools !== undefined;
async function markReady(review: ReviewCardData) {
setPendingReview(review.number);
setActionError(null);
try {
const result = await connectedApp.callServerTool({
name: "gitbutler_mark_review_ready",
arguments: {
repository: currentView.repository.path,
reviewNumber: review.number,
},
});
if (result.isError) throw new Error(textFromToolResult(result));
const updatedView = reviewViewFromToolResult(result);
const updatedReview = updatedView?.reviews[0];
if (!updatedReview) throw new Error("The updated review was missing from the response.");
setView((current) =>
current === null || updatedView === null ? current : mergeReviewViews(current, updatedView),
);
} catch (actionCause) {
setActionError(
actionCause instanceof Error ? actionCause.message : "Could not mark the review ready.",
);
} finally {
setPendingReview(null);
}
}
async function openReview(review: ReviewCardData) {
setActionError(null);
try {
await connectedApp.openLink({ url: review.url });
} catch (actionCause) {
setActionError(View on GitHub (pinned to 58e5313667)