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 validation errors with pgstac 0.9.0 + #169

Closed
zstatmanweil opened this issue Jul 31, 2024 · 7 comments · Fixed by #170
Closed

Search validation errors with pgstac 0.9.0 + #169

zstatmanweil opened this issue Jul 31, 2024 · 7 comments · Fixed by #170

Comments

@zstatmanweil
Copy link
Contributor

zstatmanweil commented Jul 31, 2024

I have worked through the demo and got everything working properly; however, when working through similar examples with my own database, I am seeing this error:

"detail": "2 validation errors for Search\n_where\n  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]\n    For further information visit https://errors.pydantic.dev/2.7/v/string_type\norderby\n  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]\n    For further information visit https://errors.pydantic.dev/2.7/v/string_type"

I am not having any trouble with the STAC item endpoints, but when I am using the STAC Collection endpoints or Search endpoints I see it. For example, I see this validation error when running the following:

tilejson = httpx.get(
    f"{raster_endpoint}/collections/{collection_id}/WebMercatorQuad/tilejson.json",
    params = (
        ("assets", "data"),  # THIS IS MANDATORY
        ("minzoom", 12),
        ("maxzoom", 19), 
    )
).json()

I am on pgstac 0.9.1 and am thinking that may be the issue so I tried the demo with the pgstac image v0.9.1 and confirmed I saw the same error and was no longer able to run the demo.

Is titiler-pgstac not compatible with pgstac 0.9.X yet? Anything easy that can be tweaked to get it working?

@vincentsarago
Copy link
Member

thanks for the report, I'll have a look 🙏

@zstatmanweil
Copy link
Contributor Author

I think I see the issue, and I think it may be a pgstac issue. In pgstac v0.9.1, none of the _where or orderby fields are populating in the search table, and the search_wheres is not being populated at all. I have mostly been using our database with stac-fastapi, where this hasn't been an issue as it would just affect performance. But here in titiler, it is throwing a pydantic error as it expects those columns to be populated.

I will open an issue in pgstac.

@vincentsarago
Copy link
Member

we could patch titiler-pgstac and make https://github.com/stac-utils/titiler-pgstac/blob/main/titiler/pgstac/model.py#L200-L201 optional

@zstatmanweil
Copy link
Contributor Author

That would be great if it doesn't affect the actual searches run. I think the search_wheres logic is mostly for caching, right?

@vincentsarago
Copy link
Member

it won't affect anything on titiler-pgstac side. The search model is just used in the /info and in the /register endpoints.

I've tried a simple fix in #170 but that's not enough 😅

@zstatmanweil
Copy link
Contributor Author

Ah yeah, failing a test. Interestingly _where and orderby are not constrained to not be null in the actual database.

Your suggestion does make titiler-pgstac usable for me though! It seems to be working.

@vincentsarago
Copy link
Member

vincentsarago commented Aug 1, 2024

so there is another change in pgstac, before 0.9 when a search didn't exist, pgstac was returning a Search with Query Hash {self.input} Not Found" message

now we get psycopg.errors.NotNullViolation: null value in column "search" of relation "searches" violates not-null constraint , seems that stac-utils/pgstac@v0.8.5...v0.9.0#diff-bc6e3521e72191870b534855e7973b456f89a1756315fb23510b50d926238f3aR51-R52 is not reached

cc @bitner

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

Successfully merging a pull request may close this issue.

2 participants