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

sortby parameter is typed as List[str], but value must be List[Dict[str,str]] when doing POST search #155

Closed
philvarner opened this issue May 2, 2022 · 0 comments
Assignees
Milestone

Comments

@philvarner
Copy link
Collaborator

philvarner commented May 2, 2022

The search sortby parameter is typed as List[str], I assume expecting a GET value like +datetime,-eo:cloud_cover to be passed.
However, when doing POST search, the server must be a list of sort objects, e.g.,

sortby=[
            {
                "field": "properties.eo:cloud_cover",
                "direction": "asc"
            }
        ]

When running this query, the failure message is because it's putting a string value for sortby (or a list?) but then pydantic validation is expecting a dict:

$ stac-client search  https://planetarycomputer.microsoft.com/api/stac/v1 -c sentinel-2-l2a --bbox -72.5 40.5 -72 41 --sortby '+properties.datetime' --method POST
1 validation error for Request
body -> sortby -> 0
  value is not a valid dict (type=type_error.dict)

I think the correct thing to do is for the type to be Union[List[str], List[Dict[str,str]] ], and then have a dynamic check for the type in the list depending on if GET or POST is being used.

@matthewhanson matthewhanson added this to the 0.4.0 milestone May 24, 2022
@philvarner philvarner self-assigned this May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants