Skip to content

Fix invalid Windows AppxManifest from wildcard scope_extensions (#6104)#6111

Open
JudahGabriel wants to merge 2 commits into
mainfrom
judahgabriel-fix-windows-manifest-invalid
Open

Fix invalid Windows AppxManifest from wildcard scope_extensions (#6104)#6111
JudahGabriel wants to merge 2 commits into
mainfrom
judahgabriel-fix-windows-manifest-invalid

Conversation

@JudahGabriel

Copy link
Copy Markdown
Contributor

Problem

Fixes #6104. Packaging for the Microsoft Store / Windows platform fails for PWAs whose web manifest declares a wildcard scope_extensions origin (e.g. https://*.globelink.com). pwa_builder.exe fails with:

appx_package_builder.cc:455] packageWriter->Close(...) failed: The Appx package's manifest is invalid. (0x80080204)

Root cause

The failure happens inside Edge's pwa_builder.exe, not in our own package assembly. PWABuilder always passes "extensions": "appurihandler", so pwa_builder.exe turns each scope_extensions origin into a <uap3:Host Name="..."> entry under windows.appUriHandler. Per the schema, Host Name must be a fully-qualified domain name — wildcards like *.globelink.com are rejected, so the generated AppxManifest violates the schema and Close() fails with 0x80080204 (APPX_E_INVALID_MANIFEST).

Changes

  • WebManifestSanitizer (new): sanitizes the web manifest before it's written to the temp file handed to pwa_builder.exe. For scope_extensions it:
    • collapses wildcard origins to their parent domain (https://*.globelink.comhttps://globelink.com),
    • drops origins that can't be represented as a valid host (e.g. bare https://*),
    • de-duplicates the resulting origins.
    • Only the file passed to pwa_builder.exe is affected; options.Manifest (used for images, start URL, etc.) is left untouched to keep the blast radius minimal.
  • WebManifestFinder.GenerateManifestFile: routes the manifest through the sanitizer.
  • PwaBuilderWrapper.CreatePwaBuilderCliError: on any pwa_builder.exe failure, capture the generated AppxManifest (read from the output directory, since it's written before the packaging Close) and the source web manifest in the logged exception — both as exception.Data entries and as structured ILogger properties, so App Insights captures them for diagnosing any future invalid-manifest case.

Testing

  • dotnet build succeeds (only pre-existing nullable warnings).
  • Ran WebManifestSanitizer.Sanitize against the exact scope_extensions from the issue; output contained only valid, wildcard-free, de-duplicated origins.

Notes / limitations

When enableWebAppWidgets is true, pwa_builder.exe fetches the manifest live instead of using our file, so a wildcard origin there still can't be sanitized. That's a narrow edge case outside the reported scenario; the improved error logging will surface it if it occurs.

Wildcard scope_extensions origins (e.g. https://*.example.com) caused pwa_builder.exe to emit an invalid <uap3:Host Name> in the AppxManifest, failing package creation with error 0x80080204.

- Add WebManifestSanitizer that collapses wildcard scope_extensions origins to their parent domain, drops unrepresentable origins, and dedupes before the manifest is written to the file passed to pwa_builder.exe.

- On pwa_builder.exe failures, capture the generated AppxManifest and the source web manifest in the logged exception (App Insights) to aid future diagnosis.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thanks @JudahGabriel 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 🙌

@JudahGabriel

Copy link
Copy Markdown
Contributor Author

It appears this is still broken when deploying to staging. More testing needed.

@hsrahofficial-prog

Copy link
Copy Markdown

Now Package for Android is working properly but package for microsoft store is still showing an error please help me with this

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.

[BUG: Error 500 appearing while generating a package]

3 participants