Skip to content

Detect invalid manifest images during analysis; improve MIME error recovery in Google Play packaging#6133

Open
JudahGabriel with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-google-play-package-error-again
Open

Detect invalid manifest images during analysis; improve MIME error recovery in Google Play packaging#6133
JudahGabriel with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-google-play-package-error-again

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

When a PWA's manifest references missing images (e.g., a Render.com SPA serving index.html for missing .png paths), analysis was passing IconsAreFetchable as valid, allowing Google Play packaging to proceed and fail with Bubblewrap's cryptic "Could not find MIME for Buffer" error.

Analysis fix — ImageValidationService.cs

New content-type check in TryDecodeImageAsync: After fetching the image body via GET, the response Content-Type is now validated before attempting Image.IdentifyAsync. This catches the SPA soft-404 pattern where a HEAD request returns Content-Type: image/png (MIME-sniffed from the URL extension) but the GET body returns Content-Type: text/html:

var responseContentType = response.Content.Headers.ContentType?.MediaType;
if (!string.IsNullOrEmpty(responseContentType)
    && !responseContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase)
    && responseContentType != "application/octet-stream")
{
    return ImageDecodeResult.Undecodable; // HTML served for a .png → invalid
}

application/octet-stream is excluded since some servers use it for valid binary downloads.

CancellationToken threading: TryDecodeImageAsync, ValidateFetchedImageAsync, and TryImageExistsAsync now pass the cancellation token through all HTTP requests and stream reads. Previously the decode-validation GET had no cancellation, so it wouldn't respect the 180-second analysis job timeout.

Packaging recovery fix — packageCreator.ts

Added "Could not find MIME for Buffer" to the set of errors that trigger a retry via the PWABuilder image proxy. The proxy (getSafeImageForAnalysis) validates image bytes server-side and returns a clear 400 for missing/corrupt images, replacing the opaque Bubblewrap error with actionable feedback.

const isInvalidImageMime = errorMessage.includes('Could not find MIME for Buffer');
if (is403Error || isTimeout || isRunDotAppManifestError || isWrongContentType || isInvalidImageMime) {
    // retry with proxied URLs...
}

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thanks @Copilot for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

Copilot AI linked an issue Jul 14, 2026 that may be closed by this pull request
…g error handling

- In TryDecodeImageAsync: pass CancellationToken to HTTP request and stream operations so decode validation respects job timeouts
- In TryDecodeImageAsync: check the GET response's content-type before attempting image decode. When a hosting platform (e.g. Render.com with SPA routing) serves HTML for a missing .png file, the GET response's Content-Type may differ from the HEAD response. Detecting text/html (etc.) early avoids a spurious pass and fails fast with a clear Undecodable result.
- In ValidateFetchedImageAsync: pass CancellationToken through to TryDecodeImageAsync
- In TryImageExistsAsync: pass CancellationToken through to ValidateFetchedImageAsync
- In packageCreator.ts: add 'Could not find MIME for Buffer' to the list of Bubblewrap errors that trigger a retry using the PWABuilder image proxy, which validates images server-side and returns a clearer error when an image is missing or corrupt
Copilot AI changed the title [WIP] Fix error creating Google Play package Detect invalid manifest images during analysis; improve MIME error recovery in Google Play packaging Jul 14, 2026
Copilot AI requested a review from JudahGabriel July 14, 2026 17:31
@JudahGabriel
JudahGabriel marked this pull request as ready for review July 14, 2026 22:48
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.

Error creating Google Play package

2 participants