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

Abierto
#844 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
android, javascript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

[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.
Lenguaje dominante
JavaScript
Estrellas
29
Forks
6
Merge medio
2 d 1 h
PR fusionados (30 d)
76

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wordpress-mobile/GutenbergKit

Todos los issues de wordpress-mobile/GutenbergKit

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.