fix: update template retrieval and response handling#2663
Conversation
📝 WalkthroughWalkthroughAPI template payloads are now wrapped as Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Router as LegacyRouter
participant API as TemplatesAPI
participant Gallery as TemplateGallery
participant SDK as HTTP_SDK
rect rgba(200,200,255,0.5)
Client->>Router: GET /v1/templates/:id.json?foo=bar
Router->>Client: 301 redirect to /v1/templates/:id?foo=bar
end
rect rgba(200,255,200,0.5)
Client->>API: GET /v1/templates/:id?foo=bar
API->>Gallery: read cache file for :id
Gallery-->>API: returns JSON string -> parse -> { data: template }
API-->>Client: 200 { data: template }
end
rect rgba(255,200,200,0.5)
SDK->>API: GET /v1/templates/:id
API-->>SDK: 200 { data: template }
SDK->>SDK: extract response.data -> TemplateOutput
SDK-->>Caller: TemplateOutput
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2663 +/- ##
==========================================
+ Coverage 51.32% 53.75% +2.42%
==========================================
Files 1054 1055 +1
Lines 29570 29307 -263
Branches 6628 6333 -295
==========================================
+ Hits 15177 15754 +577
+ Misses 14012 13285 -727
+ Partials 381 268 -113
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/api/src/routers/legacyRouter.ts`:
- Around line 194-200: The redirect for requests handled in the legacyRouter.get
handler strips query parameters when rewriting "id.json" to "id" — update the
handler (the async callback that reads c.req.param("id") and calls c.redirect)
to preserve the original query string: extract the raw query (e.g., from
c.req.url or c.req.query/rawQuery depending on framework) and append it
(prefixed with ? if non-empty) to the redirect target
`/v1/templates/${templateId}` before calling c.redirect with redirectStatusCode
so any ?foo=bar is forwarded to the new URL.
Summary by CodeRabbit
Bug Fixes
Chores