Skip to content

fix(api): /pwa_listing 500'd on non-JSON 200 manifest bodies — now NO_PWA (3.16.2) - #684

Open
jacoby149 wants to merge 6 commits into
devfrom
jacoby149/pwa-listing-json-decode-error
Open

fix(api): /pwa_listing 500'd on non-JSON 200 manifest bodies — now NO_PWA (3.16.2)#684
jacoby149 wants to merge 6 commits into
devfrom
jacoby149/pwa-listing-json-decode-error

Conversation

@jacoby149

Copy link
Copy Markdown
Owner

What

The dev store 500'd with JSONDecodeError: Expecting value: line 1 column 1 (char 0) on GET /pwa_listing?url=https://dev.web10.app/docs/media/index.html.

Root cause

The registered app URL is a file (.../index.html), so the manifest lookup hits .../index.html/manifest.json — the static server's SPA fallback answers that with HTML + 200. json.loads() raised JSONDecodeError (a ValueError, not a RequestException), which the endpoint's except requests.exceptions.RequestException never caught → 500.

The designed behavior (D47): no manifest → NO_PWA (401) → the store falls back to the registered name, then the host.

Fix

  • Catch json.JSONDecodeError + UnicodeDecodeErrorNO_PWA, with a [pwa_listing] log line at each NO_PWA decision point.
  • Latent bug in the same call: requests.get(url, {"Accept": ...}) passed the header dict as the params positional — the Accept header was going out as a query string. Now headers=.
  • Regression test: 200 with an HTML body → 401, never a 500.

Notes

The deeper data issue is left alone (a D47 identity call, not a bug): the media demo is registered under its index.html file URL on dev, and a file URL can never have a manifest at {url}/manifest.json — the store now degrades gracefully instead of 500ing.

715 API tests green.

…_PWA (3.16.2)

A registered file URL (.../index.html) makes the manifest lookup hit
<file>/manifest.json, which the SPA fallback answers with HTML + 200.
json.loads raised JSONDecodeError (a ValueError, not a RequestException)
which the except clause never caught. Now: NO_PWA + [pwa_listing] log,
and the Accept header actually goes in headers= (was a query param).
…rsion collision with the discover-group 3.16.2)
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.

1 participant