Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search errors messages should be JSON, not plain text #151

Open
gadomski opened this issue Feb 2, 2023 · 1 comment
Open

Search errors messages should be JSON, not plain text #151

gadomski opened this issue Feb 2, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@gadomski
Copy link
Contributor

gadomski commented Feb 2, 2023

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)"}
@mmcfarland
Copy link
Member

IIRC, this was added after some feedback around text vs json error responses. However, if it's invalid against the stac-api spec we should remove. I'll add an internal issue to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants