stac-fastapi icon indicating copy to clipboard operation
stac-fastapi copied to clipboard

PUT "/collections/{collection_id}" throws "update_collection() missing 1 required positional argument: 'collection'"

Open avbentem opened this issue 10 months ago • 3 comments

#630 fixed the update collection REST endpoint in the "transactions" extension, to properly include the collection's id in /collections/{collection_id}. Nice.

However, when the endpoint is registered it still only expects a Collection in the JSON payload, without defining the new URL segment. This makes the first update_collection argument collection_id being passed the full JSON payload, and makes collection being empty.

This throws update_collection() missing 1 required positional argument: 'collection'.

I'll create a PR with a fix.

avbentem avatar Apr 19 '24 13:04 avbentem

Hi @avbentem. Thanks for this. What stac-fastapi backend are you using?

jonhealy1 avatar Apr 20 '24 10:04 jonhealy1

Hi @jonhealy1 sorry for only seeing your question today. I'm not actually using any backend yet. (I'll likely use a bespoke one, combing Google cloud storage with PostGIS.) But I ran into this bug when setting up a basic project structure, that basically only implements the abstract methods to print the requests. (Kind of like in the tests I added.)

Wondering why you're asking. Do you think that some of the stac-utils provided backends (like stac-fastapi-pgstac or stac-fastapi-sqlalchemy) would not suffer from this bug? If that would be the case then I'd guess that those backends are not using the abstract classes that this very stac-fastapi provides?

avbentem avatar Apr 23 '24 07:04 avbentem

Ok thanks for the clarification. stac-fastapi-pgstac and stac-fastapi-elasticsearch-opensearch seem to be fine. You may be right - something to look into.

jonhealy1 avatar Apr 23 '24 08:04 jonhealy1