Skip to content

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
browser-act:mainfrom
ibraram100:fix/facebook-page-profile-posts-stale-doc-id
Open

ibraram100 wants to merge 1 commit into
browser-act:mainfrom
ibraram100:fix/facebook-page-profile-posts-stale-doc-id

Conversation

@ibraram100

Copy link
Copy Markdown

Problem

get-page-posts.py hard-codes a persisted-query doc_id and a list of
__relay_internal__pv__* "provided variables". Facebook has since
rotated both, so every call now fails with:

"A server error missing_required_variable_value occured."

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 value

The 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 extractMedia and the count
extraction 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

…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>
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