webstatus.dev icon indicating copy to clipboard operation
webstatus.dev copied to clipboard

[Bug] Invalid queries returning 5xx errors

Open jcscottiii opened this issue 1 year ago • 4 comments

Expected behavior

  • Go to the home page
  • Type an incomplete search term. Example: available_on without the colon and value
  • Get the 400 page

Actual behavior

  • Go to the home page
  • Type an incomplete search term. Example: available_on without the colon and value
  • Get the 500 page

Other notes:

  • This was found by looking at the logs image
  • Typing the term with the colon (available_on:) returns a 400 error like expected

jcscottiii avatar May 15 '24 13:05 jcscottiii

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

jcscottiii avatar May 15 '24 13:05 jcscottiii

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 -
  • 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 -
  • 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
  • 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

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.

jcscottiii avatar Jun 12 '24 12:06 jcscottiii

Definition of done for this bug:

  • [ ] Modify the grammar and run make gen to generate the generated files
  • [ ] Make any necessary changes to the implemented interface
  • [ ] Add test cases to the bad input test to catch the above queries

jcscottiii avatar Jun 12 '24 12:06 jcscottiii

If this is not urgent I can look into it in the next few days/weeks.

past avatar Jun 13 '24 22:06 past

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.
    • image

jcscottiii avatar Oct 21 '24 14:10 jcscottiii

From Nov 20 report:

Query: name:"has()" OR name:light-dark

jcscottiii avatar Nov 20 '24 17:11 jcscottiii

New report:

image

A few things happening:

  1. 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
  1. Some queries did not do the date range and instead only provided a single date

jcscottiii avatar Jan 02 '25 18:01 jcscottiii