Skip to content

Validate empty query body and improve errors#33

Merged
thehabes merged 1 commit into
mainfrom
29-post-query-returns-500-for-and-bodies
Mar 23, 2026
Merged

Validate empty query body and improve errors#33
thehabes merged 1 commit into
mainfrom
29-post-query-returns-500-for-and-bodies

Conversation

@cubap
Copy link
Copy Markdown
Member

@cubap cubap commented Mar 20, 2026

Reject empty JSON query bodies ('{}' or '[]') with a 400 error to prevent accidental all-data queries. Also set a 400 status for invalid limit/skip inputs and propagate the error status and message in the response (res.status(err.status ?? 500).send("Caught " + err.message)). Adds clearer error creation and handling for client input validation.

Reject empty JSON query bodies ('{}' or '[]') with a 400 error to prevent accidental all-data queries. Also set a 400 status for invalid `limit`/`skip` inputs and propagate the error status and message in the response (res.status(err.status ?? 500).send("Caught " + err.message)). Adds clearer error creation and handling for client input validation.
@cubap cubap linked an issue Mar 20, 2026 that may be closed by this pull request
@cubap cubap requested a review from thehabes March 20, 2026 16:03
Copy link
Copy Markdown
Member

@thehabes thehabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and confirmed that POST /query {}, [], and bodies all have a 400 error with an appropriate message. Also confirmed that a body of actual null and undefined results in a 400, which is handled correctly by express.

@thehabes thehabes merged commit 075ff35 into main Mar 23, 2026
3 checks passed
@thehabes thehabes deleted the 29-post-query-returns-500-for-and-bodies branch March 26, 2026 15:22
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.

POST /query returns 500 for {} and [] bodies

2 participants