Android: media uploads don't recover from post-processing failures when the REST API is cross-origin

オープン
#844 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
android, javascript

調査の方向性

Start with the limitation described in the comment above apiFetch.use( nativeMediaUploadMiddleware ) in src/utils/api-fetch.js, then trace Android’s upload server and cross-origin request handling. Compare the two proposed fixes: starting the native upload server when credentials exist, or adding a REST relay like iOS’s gbk-rest: relay. Done means failed post-processing can be retried and orphaned attachments cleaned up for the affected Android uploads.

索引モデルが issue の本文から書いたものです。

説明

[Type] Bug Android

On Android, a media upload that fails in server-side post-processing is not recovered when the site's REST API is on another origin and the host hasn't set a mediaProcessor or mediaUploader. The user is left with an orphaned attachment, and retrying duplicates it. This is the bug #594 fixes everywhere else.

Follow-up from #594.

What happens

When wp_generate_attachment_metadata() fatals, WordPress returns a 5xx and sends the new attachment's ID in X-WP-Upload-Attachment-ID. Core's mediaUploadMiddleware, registered in #594, reads that header to retry post-process and, if every retry fails, to delete the attachment.

Without a mediaProcessor or mediaUploader, Android doesn't start the native upload server, so the upload goes straight from the web view to WordPress. A cross-origin page can only read the response headers the server lists in Access-Control-Expose-Headers. WordPress doesn't list X-WP-Upload-Attachment-ID, so core never sees the ID. No post-process retry and no cleanup are sent.

Who is affected

Android hosts without a mediaProcessor or mediaUploader, editing a site whose REST API is not on the site's own origin. The main case is WP.com sites, whose API is public-api.wordpress.com. Its CORS response exposes only X-WP-Total, X-WP-TotalPages, Link, checked on 2026-10-29.

Not affected:

  • iOS: every upload with site credentials goes through native code, which exposes the header. Verified in the Simulator for #594.
  • Android with a mediaProcessor or mediaUploader: uploads go through the loopback server, which exposes the header and also relays the cleanup DELETE.
  • Android on a self-hosted site: GutenbergView serves the editor from the site's origin, port included, so the REST API is same-origin. Retry and cleanup both work directly.

Possible fixes

1. Start the native upload server whenever site credentials exist

Every upload and media delete would then go through native code, as on iOS. This is the smaller change, but it adds a full file copy for hosts that don't process media today.

2. Add a REST relay on Android

Match iOS's gbk-rest: relay, so requests to other origins are sent from native code. This is a larger change, and it also covers other headers WordPress hides cross-origin, such as Allow.

Related

  • The comment above apiFetch.use( nativeMediaUploadMiddleware ) in src/utils/api-fetch.js describes this limitation. It was corrected in e9306abbc, on #594.
主要言語
JavaScript
スター
29
フォーク
6
平均マージ
2日 1時間
マージ済み PR(30日)
76

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wordpress-mobile/GutenbergKit のほかの issue

wordpress-mobile/GutenbergKit の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。