microsoft / microsoft/planetary-computer-apis
Search errors messages should be JSON, not plain text
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 129
- Forks
- 33
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 1
Description
Describe the bug
As described https://github.com/stac-utils/stac-fastapi/issues/463#issuecomment-1412811704, the error response from the /search endpoint (and others) should be JSON. It looks like the Planetary Computer is opting-in to plaintext responses: https://github.com/microsoft/planetary-computer-apis/blob/95190c56b70a5c824af25b68fba7d0d45d255451/pcstac/pcstac/main.py#L138-L142
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)"}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /search endpoint and reproduce the supplied curl request, then trace how its validation error is converted into an HTTP response. Done means the failing request returns a 400 response with application/json and the shown code and description fields instead of plain text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100