Describe the bug
As described stac-utils/stac-fastapi#463 (comment), the error response from the /search endpoint (and others) should be JSON. It looks like the Planetary Computer is opting-in to plaintext responses:
|
@app.exception_handler(RequestValidationError) |
|
async def validation_exception_handler( |
|
request: Request, exc: RequestValidationError |
|
) -> PlainTextResponse: |
|
return PlainTextResponse(str(exc), status_code=400) |
Is there a reason to not return JSON here?
To reproduce
$ curl -i --json @query.json https://planetarycomputer.microsoft.com/api/stac/v1/search
HTTP/2 400
content-length: 124
content-type: text/plain; charset=utf-8
strict-transport-security: max-age=15724800; includeSubDomains
access-control-allow-origin: *
access-control-allow-credentials: true
x-cache: CONFIG_NOCACHE
x-azure-ref: 0UNLaYwAAAADvTHj17Z8kSZvAjSBV+G7DV1NURURHRTA4MTUAOTI3YWJmYTYtMTlmNi00YWYxLWEwOWQtYzk1OWQ5YTFlNjQ0
date: Wed, 01 Feb 2023 20:57:52 GMT
1 validation error for Request
body -> intersects
intersects and bbox parameters are mutually exclusive (type=value_error)
Expected behavior
$ curl -si --json @query.json http://localhost:8080/search
HTTP/1.1 400 Bad Request
date: Thu, 02 Feb 2023 14:32:46 GMT
server: uvicorn
content-length: 176
content-type: application/json
{"code":"RequestValidationError","description":"1 validation error for Request\nbody -> intersects\n intersects and bbox parameters are mutually exclusive (type=value_error)"}
Describe the bug
As described stac-utils/stac-fastapi#463 (comment), the error response from the
/searchendpoint (and others) should be JSON. It looks like the Planetary Computer is opting-in to plaintext responses:planetary-computer-apis/pcstac/pcstac/main.py
Lines 138 to 142 in 95190c5
Is there a reason to not return JSON here?
To reproduce
Expected behavior
$ curl -si --json @query.json http://localhost:8080/search HTTP/1.1 400 Bad Request date: Thu, 02 Feb 2023 14:32:46 GMT server: uvicorn content-length: 176 content-type: application/json {"code":"RequestValidationError","description":"1 validation error for Request\nbody -> intersects\n intersects and bbox parameters are mutually exclusive (type=value_error)"}