ckan / ckan

CKAN is an open-source DMS (data management system) for powering data hubs and data portals. CKAN makes it easy to publish, share and use data. It powers catalog.data.gov, open.canada.ca/data, data.humdata.org among many other sites.
https://ckan.org/
Other
4.43k stars 1.98k forks source link

Updating a non-existing resource causes an internal sever error #6925

Open bzar opened 2 years ago

bzar commented 2 years ago

CKAN version master

Describe the bug Trying to update a resource that does not exist causes an internal server error instead of a not found error

Steps to reproduce

Expected behavior

Additional details Caused by this line being placed before these lines.

TomeCirun commented 2 years ago

Hey, @bzar, I just tested this via curl, I sent an id that doesn't exist, and it gives me the proper error message: 404 not found. https://github.com/ckan/ckan/blob/7586d78682c30f205027522214f33ee2bf413055/ckan/logic/action/update.py#L73-L76 if you look at the code you can see in line 73 we have another check

if resource is None

and here are my logs: image

image

Zharktas commented 2 years ago

It's actually 2.9 and earlier issue, master has a check for it. 2.9 does not https://github.com/ckan/ckan/blob/ca537ad25e13320b6fbf91f41031eadc30500f12/ckan/logic/action/update.py#L73-L79

bzar commented 2 years ago

Yeah, my bad. I tested this on our 2.9.5 instance and demo.ckan.org, saw the same order for those lines in master and assumed it was still an issue.