Skip to content

fix(facebook): use rupload upload_url for story video transfer - #360

Closed
Cryptoom wants to merge 3 commits into
trypostit:mainfrom
Cryptoom:upstream-fix/publish-story-rupload
Closed

Cryptoom wants to merge 3 commits into
trypostit:mainfrom
Cryptoom:upstream-fix/publish-story-rupload

Conversation

@Cryptoom

Copy link
Copy Markdown

Summary

publishStory() ignored the upload_url returned by the Video Stories API's start phase and instead POSTed the media's hosted URL as a body field called video_file_chunk to /{video_id} on the regular Graph host. That is not a valid transfer step for this API: Facebook's Video Stories API always returns {video_id, upload_url}, and the transfer phase has to reach the rupload host at upload_url, not graph.facebook.com.

Every Facebook Story publish failed with Graph API error 6000 ("Problem with file. Try with another file."), regardless of the actual video (reproduced with and without an audio track).

Fix

Mirrors the already-working publishReel() transfer step: download the hosted media and stream raw bytes to upload_url with the Offset/file_size headers rupload requires. The documented file_url-header shortcut is the same shortcut publishReel()'s own comment already flags as unreliable.

Verified against Meta's documented start/transfer/finish flow (cross-checked against a third-party Facebook Stories API writeup that matches the official docs).

Test plan

  • php -l on both changed files
  • Updated FacebookPublisherTest.php mirrors the already-passing reel test's assertions against the new transfer contract
  • Could not run the full local test suite on this machine (no working Postgres test database, port 5432 held by an unrelated project's container). CI should cover this.

publishStory() ignored the upload_url returned by the video_stories
start phase and instead POSTed the media's hosted URL as a body field
called video_file_chunk to /{video_id} on the regular Graph host. That
is not a valid transfer step for this API: Facebook's Video Stories
API always returns {video_id, upload_url}, and the transfer phase has
to reach the rupload host at upload_url, not graph.facebook.com.

Every Facebook Story publish failed with Graph API error 6000
("Problem with file. Try with another file."), regardless of the
actual video (reproduced with and without an audio track). Fixed by
mirroring the already-working publishReel() transfer step: download
the hosted media and stream raw bytes to upload_url with the
Offset/file_size headers rupload requires, since the documented
file_url-header shortcut is the same shortcut publishReel()'s own
comment already flags as unreliable.

Verified against Meta's documented start/transfer/finish flow (Ayrshare's
Facebook Stories API writeup, which matches the official docs). Could not
run the local test suite (no working Postgres test database for this repo
on this machine, port 5432 is held by an unrelated project's container);
`php -l` passes on both changed files, and the updated test mirrors the
already-passing reel test's assertions against the new transfer contract.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Cryptoom added a commit to Cryptoom/trypost that referenced this pull request Sep 17, 2026
Olli explizit: "nein wir wollen nicht helfen!" Kein Issue-Kommentar,
kein PR-Angebot an trypostit#228. Der separate publishStory()-
Fix (trypostit#360) bleibt unberuehrt, das war ein echter Bug-Fix, kein Feature-
Beitrag.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@paulocastellano

Copy link
Copy Markdown
Contributor

Thank you @Cryptoom i will review it soon.

Paulo Castellano added 2 commits September 18, 2026 08:50
The transfer already matches publishReel(); the long why belongs in the PR, not the publisher.
Extract the start/rupload/finish sequence into publishResumableVideo,
pin the upload_url host to config, require success:true before finish,
guard temp file/filesize/fopen failures, and require a video for both
formats. Tests now cover Reels and Stories through a shared dataset.
@paulocastellano

Copy link
Copy Markdown
Contributor

Thanks for this, @Cryptoom — your diagnosis was right: the transfer was posting video_file_chunk to the Graph /{video_id} node, so the upload_url session stayed empty and finish failed with 6000.

We went with the hosted-file variant of the same official flow in #361: file_url header on the upload_url plus a status poll before finish, so the worker doesn't download and re-upload the video. Reels stay as they are in main.

Keeping this open until #361 is verified and merged, then I'll close it.

@paulocastellano

Copy link
Copy Markdown
Contributor

Closing in favor of #361, which applies the fix from main with the hosted-file (file_url) flow. Thanks again for tracking down the root cause.

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