[Bug] Invalid queries returning 5xx errors
Expected behavior
- Go to the home page
- Type an incomplete search term. Example:
available_onwithout the colon and value - Get the 400 page
Actual behavior
- Go to the home page
- Type an incomplete search term. Example:
available_onwithout the colon and value - Get the 500 page
Other notes:
- This was found by looking at the logs
- Typing the term with the colon (
available_on:) returns a 400 error like expected
It is likely getting caught in the ANY_VALUE term
May need to change the grammar to be something like this:
search_criteria:
generic_search_term
- | ANY_VALUE; // Default to ANY_VALUE search without "name:" prefix.
+ | ('name:' ANY_VALUE); // Implicit name search for ANY_VALUE
From the Jun 11, 2024 error report
Here are some other invalid queries that should return 4xx instead of 5xx
- https://api.webstatus.dev/v1/features?q=available_on%3Achrome%20available_on%3Afirefox%20available_on%3Asafari%20baseline_status%3Awidely%20name%3A%22a%20substring%22%20baseline_status%3Awidely%20-&page_size=25
- Query:
available_on:chrome available_on:firefox available_on:safari baseline_status:widely name:"a substring" baseline_status:widely -
- Query:
- https://api.webstatus.dev/v1/features?q=available_on%3Achrome%20available_on%3Afirefox%20available_on%3Asafari%20baseline_status%3Awidely%20name%3A%22a%20substring%22%20baseline_status%3Awidely%20-&page_size=25
- Query:
available_on:chrome available_on:firefox available_on:safari baseline_status:widely name:"a substring" baseline_status:widely -
- Query:
- https://api.webstatus.dev/v1/features?q=available_on%3Achrome%20available_on%20Secured%20AI%20available_on%3Asafari%20available_on%3Afirefox%20&page_size=25
- Query:
available_on:chrome available_on Secured AI available_on:safari available_on:firefox
- Query:
- https://api.webstatus.dev/v1/features?q=available_on%3Achrome%20available_on%20generative%20AI%20available_on%3Asafari%20available_on%3Afirefox%20&page_size=25
- Query:
available_on:chrome available_on generative AI available_on:safari available_on:firefox
- Query:
For the first two queries, there was a trailing -. We need a new way to detect if the - is by itself then return a 400
The last two queries are similar to the original report where the user submitted available_on without the colon. Since this is happening more, I wonder if there is something we can do on the frontend to prevent the users from thinking available_on is okay to submit by itself.
Definition of done for this bug:
If this is not urgent I can look into it in the next few days/weeks.
From Oct 21 report. Queries that should be returning 4xx instead of 5xx
- https://api.webstatus.dev/v1/features?q=group&page_size=25
- Query:
group - Explanation: Missing colon and value.
- Query:
From Nov 20 report:
Query: name:"has()" OR name:light-dark
New report:
A few things happening:
- The colon was not encoded for some of them (and the date is the wrong format. M-D-YYYY)
- Example bad query: https://api.webstatus.dev/v1/features?q=baseline_date:12-26-2024..1-2-2025%20AND%20baseline_status:newly
- Expected query https://api.webstatus.dev/v1/features?q=baseline_date%3A2023-01-01..2025-01-02%20AND%20baseline_status%3Anewly
- Some queries did not do the date range and instead only provided a single date