Skip to content

Fix BadMapError when page param is not using bracket notation#407

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
olivermt:main
Jan 15, 2026
Merged

Fix BadMapError when page param is not using bracket notation#407
zachdaniel merged 1 commit intoash-project:mainfrom
olivermt:main

Conversation

@olivermt
Copy link
Contributor

A client complained of 500 errors when they were sending query params as json in the query param by accident. It should return a structured error instead of 500'ing.

Issue and fix:
When clients send page parameter as a string (e.g., page={"limit":1})
instead of bracket notation (page[limit]=1), the pagination code would
crash with a BadMapError when calling Map.fetch on the string.

This adds a guard clause to fetch_pagination_parameters that detects
when page is a binary string and returns a structured 400 error
explaining the correct format, instead of crashing with a 500.

JSON:API spec requires bracket notation for nested query parameters.

When clients send page parameter as a string (e.g., page={"limit":1})
instead of bracket notation (page[limit]=1), the pagination code would
crash with a BadMapError when calling Map.fetch on the string.

This adds a guard clause to fetch_pagination_parameters that detects
when page is a binary string and returns a structured 400 error
explaining the correct format, instead of crashing with a 500.

JSON:API spec requires bracket notation for nested query parameters.
@zachdaniel zachdaniel merged commit 550da75 into ash-project:main Jan 15, 2026
23 checks passed
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

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.

2 participants