fix(api): GET /specs/:id returns paragraph tree — wire getSpecTree into the read path#158
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR fixes issue ChangesTree Reconstruction Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Closes #152
Summary
GET /specs/:idwas documented (README + OpenAPI) as returning the spec with its paragraph tree, butgetSpecHandlercalledfindSpecById, which hardcodesparts: []. The handler now callsgetSpecTree(the same reconstruction already used byPOST /specs/:id/generate, MCPget_spec, and the mockup tree endpoint) and returnsresult.tree.spec not found, thrown error → 500 withlogger.error.parts), and a new integration test inserts real paragraph rows (part + child article) and asserts the reconstructed shape —regression #152: parsed spec returns reconstructed paragraph tree, not parts: [].Design decisions
openapi.yamlalready promise the tree, and three other read paths (generate, MCP, mockup) already reconstruct it. Matching the code to the documented contract is the minimal-surprise fix; no doc changes needed.data=SpecTreeonly —referencesintentionally excluded.getSpecTreereturns{ tree, references }, but the OpenAPI contract for this endpoint isdata: SpecTree. Including references would change the documented schema (and requireopenapi.yamledits, which a parallel PR for feat(parser): surface DOCX inference conflicts via get_paragraph MCP tool #56 owns). References remain available via the generate/MCP paths; exposing them on GET can be a follow-up if wanted.findSpecByIdleft in place. It now has no non-test caller, but removing it would touchsrc/db/queries/specs.ts+src/db/index.ts— files the parallel feat(parser): surface DOCX inference conflicts via get_paragraph MCP tool #56 work is editing. This PR makes zero changes to those files (and toopenapi.yaml/README) to avoid merge conflicts. Dead-code removal is a follow-up candidate.Test Plan
pnpm lintclean (eslint + tsc --noEmit + prettier)parts.length0 ≠ 1 before the fix)src/api/specs.ts,src/api/specs.test.ts,src/api/specs.integration.test.ts) — no edits tosrc/db/queries/specs.ts,src/db/index.ts,openapi.yaml, or README (coordination with feat(parser): surface DOCX inference conflicts via get_paragraph MCP tool #56)Out of scope
referencesin the GET response,findSpecByIdremoval, openapi.yaml/README changes, pagination/perf work.Summary by CodeRabbit
Bug Fixes
Tests