{"record":{"id":"90d260f4916720d6","repo":"gitbutlerapp/gitbutler","slug":"the-detail-result-was-missing-structured-data","errorCode":null,"errorMessage":"The detail result was missing structured data.","messagePattern":"The detail result was missing structured data\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/but-mcp-app/src/WorkspaceApp.tsx","lineNumber":746,"sourceCode":"\t\ttry {\n\t\t\tconst result = await app.callServerTool({\n\t\t\t\tname:\n\t\t\t\t\tnextSelection.kind === \"commit\" ? \"gitbutler_commit_details\" : \"gitbutler_branch_details\",\n\t\t\t\targuments:\n\t\t\t\t\tnextSelection.kind === \"commit\"\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\trepository: view.repository.path,\n\t\t\t\t\t\t\t\tcommitId: nextSelection.commit.id,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\trepository: view.repository.path,\n\t\t\t\t\t\t\t\tbranch: nextSelection.reference.refName.fullName,\n\t\t\t\t\t\t\t},\n\t\t\t});\n\t\t\tif (request !== detailRequest.current) return;\n\t\t\tif (result.isError) throw new Error(textFromToolResult(result));\n\t\t\tconst nextDetail = detailViewFromToolResult(result);\n\t\t\tif (nextDetail === null) throw new Error(\"The detail result was missing structured data.\");\n\t\t\tsetDetail(nextDetail);\n\t\t} catch (caught) {\n\t\t\tif (request !== detailRequest.current) return;\n\t\t\tsetDetailError(caught instanceof Error ? caught.message : \"Could not load details.\");\n\t\t} finally {\n\t\t\tif (request === detailRequest.current) setDetailLoading(false);\n\t\t}\n\t}\n\n\tasync function handleCopy(value: string) {\n\t\tsetDetailError(null);\n\t\ttry {\n\t\t\tawait copyText(value);\n\t\t\tsetCopied(value);\n\t\t\twindow.setTimeout(() => setCopied((current) => (current === value ? null : current)), 1600);\n\t\t} catch (caught) {\n\t\t\tsetDetailError(caught instanceof Error ? caught.message : \"Could not copy the identifier.\");\n\t\t}","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/packages/but-mcp-app/src/WorkspaceApp.tsx#L728-L764","documentation":"select requires the detail tool response to carry structured data; when detailViewFromToolResult returns null (no structuredContent or unparseable shape) this invariant error is thrown even though the call reported success. It indicates a schema/contract mismatch between the app and the host tool.","triggerScenarios":"The detail tool responds successfully but with only text content, empty structuredContent, or a payload that detailViewFromToolResult cannot deserialize into a DetailView.","commonSituations":"Host and app version skew (tool response schema changed); a selection whose detail cannot be represented (e.g. a reference that vanished mid-request); host bug returning empty structured content for certain branch types.","solutions":["Log the raw tool result to see what structured content actually came back.","Refresh the workspace and retry the selection to rule out a mid-flight reference removal.","Align the but-mcp-app parser with the host's current tool schema.","Fall back to rendering the tool's text content instead of failing the panel.","File an internal-invariant bug with the payload if reproducible on matching versions."],"exampleFix":"// before\nconst nextDetail = detailViewFromToolResult(result);\nif (nextDetail === null) throw new Error(\"The detail result was missing structured data.\");\n// after\nconst nextDetail = detailViewFromToolResult(result);\nif (nextDetail === null) {\n  setDetailError(textFromToolResult(result) || \"No details available.\");\n  return;\n}","handlingStrategy":"type-guard","validationCode":"const raw = result.structuredContent;\nif (raw == null) {\n  setDetailError(textFromToolResult(result) || \"No structured detail data returned.\");\n  return;\n}","typeGuard":"function isDetailView(v: unknown): v is DetailView {\n  return typeof v === \"object\" && v !== null &&\n    \"repository\" in v && Array.isArray((v as DetailView).files ?? null);\n}","tryCatchPattern":"const nextDetail = detailViewFromToolResult(result);\nif (!isDetailView(nextDetail)) {\n  setDetailError(\"Detail unavailable for this selection.\");\n  return;\n} // skip the throw entirely\nsetDetail(nextDetail);","preventionTips":["Validate structured content shape before casting it to DetailView.","Keep the parser in sync with the host tool schema; add a schema/version handshake if possible.","Render the tool's text content as a fallback when structured data is absent.","Add tests covering empty structuredContent responses."],"tags":["mcp","schema","invariant"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}