Skip to content

fix: handle sidecar children without __typename in embed fallback - #44

Open
atsetilam wants to merge 1 commit into
govdbot:mainfrom
atsetilam:fix/instagram-sidecar-typename
Open

fix: handle sidecar children without __typename in embed fallback#44
atsetilam wants to merge 1 commit into
govdbot:mainfrom
atsetilam:fix/instagram-sidecar-typename

Conversation

@atsetilam

Copy link
Copy Markdown

Summary

  • The embed-page extraction path (GetEmbedMediaParseGQLMedia's GraphSidecar branch) failed to extract any media for Instagram carousel posts whenever the GQL API method failed first and it fell back to scraping the embed page.
  • Root cause: Instagram's embed-page JSON omits __typename on edge_sidecar_to_children nodes entirely (unlike the GQL API response), using an is_video boolean instead. The existing switch only matched on Typename, so every sidecar child resolved via the embed fallback ended up with zero formats attached, and the download later failed with no formats found for media item at index N — even though the post was public and available.
  • Fix: fall back to node.IsVideo when Typename doesn't match either known value (GraphVideo/XDTGraphVideo or GraphImage/XDTGraphImage), since is_video is present on every variant of the response.

Confirmed working against a live public carousel post that previously reproduced the bug 100% of the time.

Test plan

  • go build ./...
  • Deployed to a running instance and reproduced the original failure, then confirmed the same carousel post downloads correctly after the patch

The embed-page extraction path (GetEmbedMedia) returns edge_sidecar_to_children
nodes without a __typename field (unlike the GQL API), using an is_video
boolean instead. The sidecar-parsing switch only matched on Typename, so any
carousel post resolved via the embed fallback got items with zero formats,
failing downstream with "no formats found for media item at index N" even
though the post is public and available.
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.

1 participant