Repository navigation
fix(report-api): return 400 instead of 500 for invalid technology and date input - #156
Merged
Merged
Conversation
… date input - /v1/technologies: check for null (more than 30 technologies) before reading .length, so the request gets a 400 instead of a TypeError 500 - /v1/cwv-distribution: reject a malformed date (e.g. "undefined") with a 400 instead of passing it to BigQuery, which fails partition elimination
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two input bugs made
report-apireturn 500 for bad client input. Between them they caused 7 of the 9500responses in the last 14 days of production logs./v1/technologieswith more than 30 technologies (6 of the 500s)validateTechnologyArray()returnsnullwhen the list is longer than Firestore'sinlimit of 30.queryTechnologiesreadtechnologies.lengthbefore checking fornull, so it crashed withTypeError: Cannot read properties of null (reading 'length'), and the existing 400 error never ran. It now checks fornullfirst, the same wayqueryVersionsalready does.Example failing request:
/v1/technologies?technology=WordPress,Joomla,Drupal,…(33 technologies)./v1/cwv-distribution?date=undefined(1 of the 500s)The string
"undefined"was passed to BigQuery as@date, and the query failed withCannot query over table 'httparchive.crawl.pages' without a filter over column(s) 'date' that can be used for partition elimination. The controller now accepts onlyYYYY-MM-DDorlatestand returns a 400 validation error for anything else.Whatever sends
date=undefined(probably the Tech Report frontend building the URL before it has a date) should be fixed separately.Tests
report-api: 120/120 tests pass, lint clean.