openaq / openaq-api-v2

OpenAQ API
https://api.openaq.org
43 stars 9 forks source link

typo in url causes internal server error #164

Closed majesticio closed 1 year ago

majesticio commented 1 year ago

For example - leaving out the & in api.openaq.org/v3/locations?coordinates=35.0844,-106.6504radius=10000 will cause it to throw a 500

russbiggs commented 1 year ago

Can you add the stack trace youre getting to better describe why this is happening?

majesticio commented 1 year ago
File "/Users/openaq/Workspace/openaq-api-v2/openaq_fastapi/./openaq_fastapi/main.py", line 177, in openaq_request_validation_exception_handler
    logger.info(UnprocessableEntityLog(request=request, detail=exc.json()).json())
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for UnprocessableEntityLog
paramsObj
  dictionary update sequence element #0 has length 3; 2 is required (type=value_error)
[2023-06-09 22:06:28,207] INFO [middleware:93] {"type": "WARNING", "detail": null, "httpCode": 307, "path": "/favicon.ico", "params": "", "paramsObj": null, "paramsKeys": [], "ip": "127.0.0.1", "apiKey": null, "timing": 1.86, "rateLimiter": null, "counter": "0"}
russbiggs commented 1 year ago

Its likely coming from here: https://github.com/openaq/openaq-api-v2/blob/main/openaq_fastapi/openaq_fastapi/models/logging.py#L85

Something about how it is splitting on the "=" and "&", since the "&" is missing in your example it probably breaking how the dictionary is created

russbiggs commented 1 year ago

@majesticio can you take a stab at resolving this in a PR?