From 4797c08018dfeb516519e19192583e356d012c50 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Thu, 28 May 2026 01:53:59 -0300 Subject: [PATCH] fix(agent-skills): use res.text() for text/markdown endpoint (GAP-1 critical bug) The /api/agent-skills/[id]/raw endpoint returns text/markdown (plain string), not a JSON envelope. The client was incorrectly calling res.json() and unpacking a non-existent `body` field, causing all preview panes to show empty content. Switch to res.text() and update the test mock to match. --- .../dashboard/agent-skills/AgentSkillsPageClient.tsx | 4 ++-- tests/unit/agent-skills-page.test.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/(dashboard)/dashboard/agent-skills/AgentSkillsPageClient.tsx b/src/app/(dashboard)/dashboard/agent-skills/AgentSkillsPageClient.tsx index 6eadae3dc5..e70d5b7d10 100644 --- a/src/app/(dashboard)/dashboard/agent-skills/AgentSkillsPageClient.tsx +++ b/src/app/(dashboard)/dashboard/agent-skills/AgentSkillsPageClient.tsx @@ -95,8 +95,8 @@ export function AgentSkillsPageClient(): JSX.Element { try { const res = await fetch(`/api/agent-skills/${id}/raw`); if (!res.ok) throw new Error(`HTTP ${res.status}`); - const json = (await res.json()) as { body: string }; - setMarkdownCache((prev) => new Map(prev).set(id, json.body ?? "")); + const body = await res.text(); + setMarkdownCache((prev) => new Map(prev).set(id, body)); } catch { setMarkdownCache((prev) => { const next = new Map(prev); diff --git a/tests/unit/agent-skills-page.test.tsx b/tests/unit/agent-skills-page.test.tsx index 656eb75f00..df7acfe2ec 100644 --- a/tests/unit/agent-skills-page.test.tsx +++ b/tests/unit/agent-skills-page.test.tsx @@ -106,9 +106,9 @@ function mockFetch(skills: AgentSkill[], coverage: SkillCoverage, rawMarkdown = }); } if (/\/api\/agent-skills\/.+\/raw/.test(urlStr)) { - return new Response(JSON.stringify({ body: rawMarkdown }), { + return new Response(rawMarkdown, { status: 200, - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "text/markdown; charset=utf-8" }, }); } return new Response(JSON.stringify({}), { status: 404 });