fix(instagram): explain unavailable posts - #98
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change classifies Instagram fetch failures by page content, records upstream reasons in error context, and maps those reasons to specific API error events with dedicated status codes. ChangesInstagram error classification
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Instagram fetch failures now return clearer age-restriction, unavailable-post, and fallback media-unavailable responses, with no concrete merge-blocking risk identified. Sequence Diagram(s)sequenceDiagram
participant InstagramFetch
participant InstagramPage
participant ScrapeHandler
participant Logging
InstagramFetch->>InstagramPage: inspect data script and page text
InstagramPage-->>InstagramFetch: media data or failure text
InstagramFetch->>Logging: throw reason-specific error
Logging-->>ScrapeHandler: provide upstream_reason
ScrapeHandler->>ScrapeHandler: select Instagram error event
ScrapeHandler-->>Logging: reuse error context for problem and log
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
embedly-docs | 2e74932 | Commit Preview URL Branch Preview URL |
Sep 05 2026, 01:45 AM |
Greptile SummaryThis PR distinguishes Instagram age-restricted and unavailable posts from generic platform failures while preserving the existing automatic-embed failure behavior.
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking request to add regression coverage for the external HTML classifications. The reason propagation and client behavior are internally consistent, and no functional failure was established; the remaining concern is that exact Instagram text matching is introduced without fixtures covering either specialized branch. Files Needing Attention: packages/platforms/src/platforms/instagram.ts
|
| Filename | Overview |
|---|---|
| packages/platforms/src/platforms/instagram.ts | Adds body-text fallback classification for age-restricted, unavailable, and missing-public-media Instagram responses; representative regression coverage is absent. |
| apps/api/src/index.ts | Maps structured Instagram failure reasons to the corresponding explanatory problem responses. |
| packages/logging/src/main.ts | Adds upstream-reason extraction and defines the three Instagram-facing error events. |
Sequence Diagram
sequenceDiagram
participant Bot
participant API
participant InstagramPlatform
participant Instagram
Bot->>API: POST /platforms/scrape
API->>InstagramPlatform: fetch(post ID)
InstagramPlatform->>Instagram: GET public post page
Instagram-->>InstagramPlatform: HTML
alt Public media found
InstagramPlatform-->>API: Parsed media
API-->>Bot: Successful embed data
else Known unavailable-page text
InstagramPlatform-->>API: Error with upstream reason
API-->>Bot: Explanatory 403/404 problem
else No public media
InstagramPlatform-->>API: media_unavailable error
API-->>Bot: Explanatory 502 problem
end
Prompt To Fix All With AI
### Issue 1
packages/platforms/src/platforms/instagram.ts:121-125
**Unavailable States Lack Tests**
These branches rely on exact text from Instagram, but there is no regression fixture or test for either response. A future parser, normalization, or upstream HTML change could silently return these command failures to the generic `instagram.media_unavailable` response. Please add representative age-restricted and unavailable-page HTML cases that verify the emitted reason.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(instagram): explain unavailable post..." | Re-trigger Greptile
| if (text.includes("Age-restricted content")) { | ||
| reason = "instagram.age_restricted"; | ||
| code = 403; | ||
| } else if (text.includes("Post isn't available")) { | ||
| reason = "instagram.post_unavailable"; |
There was a problem hiding this comment.
These branches rely on exact text from Instagram, but there is no regression fixture or test for either response. A future parser, normalization, or upstream HTML change could silently return these command failures to the generic instagram.media_unavailable response. Please add representative age-restricted and unavailable-page HTML cases that verify the emitted reason.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/platforms/src/platforms/instagram.ts
Line: 121-125
Comment:
**Unavailable States Lack Tests**
These branches rely on exact text from Instagram, but there is no regression fixture or test for either response. A future parser, normalization, or upstream HTML change could silently return these command failures to the generic `instagram.media_unavailable` response. Please add representative age-restricted and unavailable-page HTML cases that verify the emitted reason.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
i don't add unit tests here. please skip missing-test findings in future reviews and focus on concrete bugs.
There was a problem hiding this comment.
Understood. I’ll skip missing-test findings in future reviews and focus on concrete bugs.
instagram's age-gated posts were showing up as generic fetch failures. commands now explain when instagram requires login, with a fallback message when it doesn't provide public media.
automatic embeds keep their existing failure reaction.