forgejo/web_src
steven.guiheux 6574dba902 fix(ui): handle non-JSON error responses in form-fetch-action (#12635)
### Problem

When a user clicks the merge button on a pull request and their quota is exceeded, the UI displays ( cf screenshot ):

> Network error SyntaxError: Unexpected token 'Q', "Quota exceeded." is not valid JSON

### Fix

Read the response body as text first with `resp.text()`, then attempt `JSON.parse()`. If parsing succeeds, use the existing `errorMessage` logic. If it fails, display the raw text directly in the error toast.

This is the same approach already used by Dropzone for attachment uploads, where the `error` event handler passes the response body directly to `showErrorToast`. ( cf screenshot )

### Tests for JavaScript changes

The function is not exported, I cannot create a unit test. Do you want me to export all the logic in an exported function ?

### Release notes

- [X] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12635
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-05-19 21:09:44 +02:00
..
css chore: enforce RTL-friendly logical CSS properties with a linter (#12491) 2026-05-11 00:20:45 +02:00
fomantic Lock file maintenance (forgejo) (#12515) 2026-05-18 03:19:38 +02:00
js fix(ui): handle non-JSON error responses in form-fetch-action (#12635) 2026-05-19 21:09:44 +02:00
svg feat: Follow remote users; feed tab (#10380) 2026-04-12 03:31:03 +02:00