Skip to content

The collections field should be submitted in HTTP requests as a list of strings #768

Description

@mcucchi9

Issue

I'm testing a STAC API developed using stac-fastapi-pgstac. When I submit the following test

stac-api-validator --root-url <root_url> --conformance item-search#sort --collection era5

I get, among others, the following error:

- [Item Search - Sort Ext] : POST <root_url>/search params=None body={"sortby": [{"field": "properties.datetime", "direction": "asc"}], "limit": 100, "collections": "era5"} had unexpected status code 400 instead of 200: 

Replicating the same request manually, I actually get a 400 Bad Request error with the following response body:

{
    "detail": [
        {
            "type": "list_type",
            "loc": [
                "body",
                "collections"
            ],
            "msg": "Input should be a valid list",
            "input": "era5"
        }
    ],
    "body": {
        "sortby": [
            {
                "field": "properties.datetime",
                "direction": "desc"
            }
        ],
        "limit": 10,
        "collections": "era5"
    }
}

This is a request validation error stating that the collections field should be a list, while it is in fact submitted as a string.

In my opinion the STAC API is behaving in the expected way: the STAC API specification for the item-search capability, in fact, states that the value of the collections should be of type array (here).

Proposed solution

The collection CLI parameter's value should be converted to a list before assigning it to the HTTP request's collections field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions