Repository navigation
fix(facebook-page-profile-posts): stale doc_id causes missing_required_variable_value; read query params at runtime - #23
Open
ibraram100 wants to merge 1 commit into
Conversation
…untime instead of hard-coding
Facebook rotates the persisted query doc_id and its __relay_internal__pv__*
provided variables when it deploys updates. The hard-coded values in
get-page-posts.py go stale, and calls fail with
"missing_required_variable_value" instead of the documented
"Unexpected response format" — the recapture steps in SKILL.md don't
even match this failure mode.
Both values are exposed by the page's own Relay modules and can be read
live instead of captured by hand:
- require('ProfileCometTimelineFeedRefetchQuery_facebookRelayOperation')
→ current doc_id
- require('ProfileCometTimelineFeedRefetchQuery.graphql')
.params.providedVariables → call .get() on each entry
The hard-coded values are kept as a fallback for when those modules
aren't loaded (e.g. calling from a non-Facebook tab).
Also updates extractMedia and the likes/comments/shares extraction:
Facebook moved multi-photo albums into per-count subattachments lists
(two_photos_subattachments, etc.) and moved reaction/comment/share
counts directly onto the UFI feedback object, so the old paths were
returning null/empty even when the query itself succeeded.
Tested against a live public Facebook Page timeline.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get-page-posts.pyhard-codes a persisted-querydoc_idand a list of__relay_internal__pv__*"provided variables". Facebook has sincerotated both, so every call now fails with:
This isn't the "Unexpected response format" failure the Known
Limitations section describes, and the documented recapture steps
(open network requests, filter by friendly name, copy doc_id by hand)
don't fix it — you'd also need to hand-copy 20+ provided variables and
repeat this every time Facebook deploys.
Fix
Both the doc_id and the provided variables are exposed by the page's
own loaded Relay modules, so the script now reads them live instead of
shipping a frozen snapshot:
require('ProfileCometTimelineFeedRefetchQuery_facebookRelayOperation')→ current doc_id string
require('ProfileCometTimelineFeedRefetchQuery.graphql').params.providedVariables→ call
.get()on each provider for its current valueThe previously hard-coded values are kept only as a fallback for when
these modules aren't loaded on the page.
While debugging I also found the response shape changed independent
of the query: multi-photo posts now nest photos under per-count
subattachment lists, and like/comment/share counts moved onto the UFI
feedback object directly. Fixed
extractMediaand the countextraction accordingly (old paths kept as fallbacks).
Testing
Verified against a live public Facebook Page (basic timeline posts,
photo posts, multi-photo album posts) — posts, media, and engagement
counts all populate correctly, and pagination works across multiple
pages.
Not included
I didn't touch anything else in this skill — this is scoped to the
stale-query bug only.
🤖 Generated with Claude Code