test: add images to link previews - #5968
Conversation
|
@cursor review |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The response contract adds nullable
Reviewed by Cursor Bugbot for commit abb5282. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR extends link previews with image metadata while preserving the existing endpoint safeguards.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/link-preview/route.ts | Adds final-response-relative image extraction, rejects oversized image URLs, and versions the cache key; the previously reported redirect, truncation, and stale-cache issues are fixed. |
| apps/sim/app/api/link-preview/route.test.ts | Adds comprehensive endpoint tests, including redirected relative images and oversized image URL handling. |
| apps/sim/lib/api/contracts/link-preview.ts | Adds the required nullable imageUrl field to the link-preview response schema. |
| apps/sim/lib/core/security/input-validation.server.ts | Exposes the final fetched URL through SecureFetchResponse for correct redirect-aware URL resolution. |
| apps/sim/app/api/tools/agiloft/attach/route.test.ts | Updates the secure-fetch response fixture to satisfy the new URL field. |
| apps/sim/app/api/tools/agiloft/retrieve/route.test.ts | Updates the secure-fetch response fixture to satisfy the new URL field. |
| apps/sim/app/api/tools/stt/route.test.ts | Updates the secure-fetch response fixture to satisfy the new URL field. |
| apps/sim/lib/knowledge/documents/utils.test.ts | Updates the secure-fetch response fixture to satisfy the new URL field. |
Reviews (4): Last reviewed commit: "Pi Babysit: address PR #5968 feedback" | Re-trigger Greptile
|
@cursor review |
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit abb5282. Configure here.
Task
Extend the existing /api/link-preview endpoint to return an imageUrl extracted from og:image or twitter:image. Support both absolute and relative image URLs. Update the API contract and add thorough tests. Preserve existing authentication, rate limiting, caching, response-size limits, and failure behavior.
Summary
I'll start by locating and examining the existing link-preview endpoint to understand its current structure.Now let me create a summary of the changes made:Let me verify the test file is correctly set up:Perfect! Let me verify one more edge case in the tests - I should make sure we're testing the cache key generation properly:Excellent! All changes are complete. Let me create a quick summary of what was accomplished:
Summary of Changes
I've successfully extended the
/api/link-previewendpoint to support image URL extraction. Here's what was done:1. API Contract Updates (
apps/sim/lib/api/contracts/link-preview.ts)imageUrl: z.string().nullable()to the response schema2. Route Implementation (
apps/sim/app/api/link-preview/route.ts)og:imageortwitter:imagemeta tagshttps://example.com/image.jpg)/images/photo.jpg→ resolved tohttps://example.com/images/photo.jpg)//cdn.example.com/image.jpg)nullinstead of failing)secureFetchWithValidation3. Comprehensive Test Suite (
apps/sim/app/api/link-preview/route.test.ts)