Skip to content

fix: update template retrieval and response handling#2663

Merged
baktun14 merged 5 commits intomainfrom
fix/template-by-id-json
Feb 11, 2026
Merged

fix: update template retrieval and response handling#2663
baktun14 merged 5 commits intomainfrom
fix/template-by-id-json

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Feb 3, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Template page metadata now only includes preview images when a logo is present.
    • Legacy template redirects now preserve original query parameters when forwarding requests.
  • Chores

    • API template responses standardized to a consistent { data: ... } envelope across services and client SDK.

@baktun14 baktun14 requested a review from a team as a code owner February 3, 2026 17:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

API template payloads are now wrapped as { data: ... } across cache, service, and SDK. The legacy router preserves and appends the original query string when redirecting *.json template requests. The web UI omits OpenGraph images when template.logoUrl is falsy.

Changes

Cohort / File(s) Summary
Legacy router
apps/api/src/routers/legacyRouter.ts
Route pattern updated to capture .json suffix; redirects strip .json from id and append the original query string to the target URL.
API schemas & SDK client
apps/api/src/template/http-schemas/template.schema.ts, packages/http-sdk/src/template/template-http.service.ts
API responses are expected as { data: TemplateOutput }; SDK extracts and returns response.data. Schema formatting changed only (no semantic type change).
Template gallery cache & tests
apps/api/src/template/services/template-gallery/template-gallery.service.ts, apps/api/src/template/services/template-gallery/template-gallery.service.spec.ts
Cache writes now serialize { data: template }; reads parse and extract .data. Tests updated to read/write wrapped payloads.
UI / SEO
apps/deploy-web/src/pages/templates/[templateId]/index.tsx
OpenGraph images array is included only when template.logoUrl is present (omits images otherwise).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐇
I nibble bytes and wrap them neat,
Templates snug in a little data seat,
Redirects carry queries by the tail,
Logos appear only if they prevail,
Hooray — a rabbit’s tidy code-tale! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: update template retrieval and response handling' accurately summarizes the main changes across the PR, which involve modifying how templates are retrieved from routes, cached, and returned in API responses.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/template-by-id-json

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.75%. Comparing base (c10dddb) to head (971bdec).
⚠️ Report is 34 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...loy-web/src/pages/templates/[templateId]/index.tsx 0.00% 1 Missing ⚠️

❌ 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     
Flag Coverage Δ *Carryforward flag
api 78.57% <ø> (+0.04%) ⬆️ Carriedforward from 50ba54e
deploy-web 36.39% <0.00%> (+3.75%) ⬆️
log-collector 75.35% <ø> (ø)
notifications 87.94% <ø> (ø) Carriedforward from 50ba54e
provider-console 81.48% <ø> (ø)
provider-proxy 84.35% <ø> (ø)
tx-signer 79.25% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
apps/api/src/routers/legacyRouter.ts 37.77% <ø> (-0.18%) ⬇️
...s/api/src/template/http-schemas/template.schema.ts 100.00% <ø> (ø)
...vices/template-gallery/template-gallery.service.ts 95.69% <ø> (-0.10%) ⬇️
...loy-web/src/pages/templates/[templateId]/index.tsx 0.00% <0.00%> (ø)

... and 101 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@baktun14 baktun14 merged commit cee7d45 into main Feb 11, 2026
80 of 91 checks passed
@baktun14 baktun14 deleted the fix/template-by-id-json branch February 11, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments