mirror of https://github.com/pixelfed/pixelfed
dev
staging
l10n_staging
shleeable-patch-1
w5
shleeable-patch-11
shleeable-patch-8
groups
vue3
v0.1.9
v0.10.0
v0.10.1
v0.10.10
v0.10.2
v0.10.3
v0.10.4
v0.10.5
v0.10.6
v0.10.7
v0.10.8
v0.10.9
v0.11.0
v0.11.1
v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.2
v0.11.3
v0.11.4
v0.11.5
v0.11.6
v0.11.7
v0.11.8
v0.11.9
v0.12.0
v0.12.1
v0.12.2
v0.12.3
v0.12.4
v0.12.5
v0.12.6
v0.12.7
v0.5.9
v0.6.0
v0.6.1
v0.7.6
v0.8.0
v0.8.5
v0.8.6
v0.9.0
v0.9.4
v0.9.5
v0.9.6
${ noResults }
1 Commits (e062a45f9abd617d496bd1b2390a82721e56611a)
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
e062a45f9a |
fix: return 422 (not 500) for ValidationException on JSON API requests
Closes #6609, closes #6610 ## Bug 1 — Handler.php returns HTTP 500 for ValidationException (#6609) `ValidationException` has no `getStatusCode()` method — only a `$status` property (default 422). The existing handler checked `method_exists($exception, 'getStatusCode')`, which returns false, so the fallback of 500 was used for every JSON API validation failure. Fix: use `$exception->status` as the fallback for `ValidationException`. ## Bug 2 — timelineHome rejects empty max_id=/min_id= parameters (#6610) The Pixelfed Android app (and other Mastodon-compatible clients such as Tusky and Ivory) send `max_id=` (empty string) on the first home timeline request. The `ConvertEmptyStringsToNull` middleware converts this to null before validation. The rule `'sometimes|integer'` still validated the key (it is "present" as null) and the `integer` rule failed on null, throwing a `ValidationException`. This then triggered bug #6609, returning HTTP 500. Every other timeline method in `ApiV1Controller` already uses `'nullable|integer'` for `max_id`/`min_id`. This commit makes `timelineHome` consistent. ## Tests `tests/Feature/HomeTimelineTest.php` adds four regression tests: 1. Validates that a non-integer `max_id` returns 422 (not 500) — catches the Handler.php regression independently of the controller fix. 2. Validates that `max_id=` (empty) returns a successful response — the exact request the Pixelfed Android app sends on first load. 3. Same for `min_id=`. 4. Validates that a non-null, non-integer `max_id` is still rejected (422), ensuring the `nullable` change does not weaken input validation. |
2 months ago |