Malformed JSON is returned as HTTP 500 instead of preserving Bottle's 400 status

Author: potatosipsCreated Jul 19, 2026Updated Jul 19, 2026

Have you checked our README?

  • I have checked the README

Have you followed our Troubleshooting?

  • I have followed your Troubleshooting

Is there already an issue for your problem?

  • I have checked older issues, open and closed

Have you checked the discussions?

  • I have read the Discussions

Have you ACTUALLY checked all these?

YES

Environment

markdown
- FlareSolverr version: 3.5.0 (official ghcr.io/flaresolverr/flaresolverr:v3.5.0 image, digest sha256:139dfee1c6f89249c8d665d1333a42e8ec74ec0a86bc6bb1c8461e10d3a66a47)
- Last working FlareSolverr version: Unknown / not tested
- Operating system: Ubuntu 24.04.4 LTS, Linux aarch64
- Are you using Docker: yes (Docker 29.6.2)
- FlareSolverr User-Agent (see log traces or / endpoint): Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
- Are you using a VPN: no
- Are you using a Proxy: no
- URL to test this issue: http://127.0.0.1:8191/v1
- Chromium major version: 148

Description

Summary

A malformed JSON request to POST /v1 is reported as HTTP 500, even though Bottle's original parsing error is an HTTP 400. The response body still exposes the original error as (400, 'Invalid JSON').

Steps to reproduce

bash
printf '{' | curl -i -X POST http://127.0.0.1:8191/v1 \
  -H 'Content-Type: application/json' \
  --data-binary @-

The same result occurs with other malformed input such as [.

Actual result

http
HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{"error": "(400, 'Invalid JSON')"}

Expected result

Malformed JSON is a client error, so Bottle's HTTP 400 status should be preserved (or an equivalent 4xx response returned) rather than converted to 500.

Likely cause

On current master, src/bottle_plugins/error_plugin.py catches every Exception, including Bottle's HTTPError(400, 'Invalid JSON'), then unconditionally sets response.status = 500. Handling/re-raising HTTPError separately would preserve the framework's status.

Impact

API clients, health monitoring, and retry logic classify malformed client requests as FlareSolverr server failures. This can cause unnecessary retries and false outage alerts.

I reproduced this repeatedly on a fresh official v3.5.0 ARM64 container, both before and after a container restart.

Logged Error Messages

2026-07-19 16:55:35 ERROR    (400, 'Invalid JSON')
2026-07-19 16:55:35 INFO     172.17.0.1 POST http://127.0.0.1:8191/v1 500 Internal Server Error
2026-07-19 16:55:35 ERROR    (400, 'Invalid JSON')
2026-07-19 16:55:35 INFO     172.17.0.1 POST http://127.0.0.1:8191/v1 500 Internal Server Error

Screenshots

No response

Source: FlareSolverr/FlareSolverr