-
Notifications
You must be signed in to change notification settings - Fork 33
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
404 error when uploading a file that fails postgres rules #94
Comments
@KatiRG This is when you are using To my understanding, I thought that when using the validation extension in What version of CKAN are you running? |
@JVickery-TBS We have the following settings:
and we are using CKAN 2.9.7. |
Update: it errors out because of a call to delete the new resource here: https://github.com/frictionlessdata/ckanext-validation/blob/master/ckanext/validation/logic.py#L679 Creating a new resource with an invalid CSV file means there is no resource in the database, therefore the call to delete it ( |
@KatiRG sorry for the sporadic replies! I am able to recreate this locally. So am just going to debug through it a bit to see what the issue is. But it looks like the Resource gets created for me, but then yes, I also get hit with that 404 but the web address is still Hopefully will have more for you soon! |
Okay I found the issue:
So I am now just debugging more here, and seeing if it would be safe to catch the NotFound exception in |
Thanks @JVickery-TBS ! I found that removing the delete action is sufficient to resolve this error. The check in If the resource is not valid (as checked by
Please check if this solution also works for you! I can make a PR if you like. |
@KatiRG The error that you original got, and that I was able to replicate was coming from Xloader. Let me know you are running with xloader plugin installed here. So, yes, the validation failure would delete the resource, but then Xloader uses I personally like to use I already have a PR on the xloader repo which would actually solve this problem: https://github.com/ckan/ckanext-xloader/pull/196/files As for the functionality of the Validation extension and how synchronis validation works. It is to my understanding that Resource do NOT get created or updated if the validation fails (which happens on form submission or API POST/PATCH). Thus, the Resource would not show up on the Dataset page. If you want to have the Resources get created even if they fail validation, then you would want to use async. This is my understanding of how the developers of the Validation extension wanted it to work. That being said, there could be another option here to make Resources that do not pass validation become Draft instead of just deleting them. |
ckan/ckanext-xloader#198 <- PR for quicker acceptance into Xloader here. qld-gov-au/ckanext-xloader#69 <- and the Queensland one, if you use that fork instead. |
@KatiRG ah sorry, I understand your "There is one issue left which is to not display the invalid resource in the dataset page" comment. Sorry! Yes, that would have probably been caused from the removal of the delete. But that would be solved by keeping the delete, and fixing the issue in Xloader. (I shall go see if datapusher also has this issue) |
@JVickery-TBS Keeping the delete doesn't resolve that last issue. With the delete in place, the user will be directed to a 404 page after adding the file: but then they can navigate via the menu back to the dataset page, and the resource will be listed: |
@KatiRG Yeah that is correct. That is because of the order of execution between Validation and Xloader extensions. So what happens is:
The Xloader extension needs to handle the exception of the Resource not existing during the submission to Xloader. Currently, it does not and really messes things up. https://github.com/ckan/ckan/blob/master/ckan/model/modification.py#L67 <- there is even a comment in this model in the exception handling:
So the issue, is that Xloader is disrupting the commit here. |
@KatiRG if you are using your own fork of Xloader, you can try to cherry pick from my commit PR here: ckan/ckanext-xloader#198 Otherwise, I don't think it should take too long for them to accept this PR. I have been doing a fair amount for Xloader this past week. |
Thanks @JVickery-TBS , I will review! I think Ian Ward has had a similar issue and got around it by disabling xloader's normal loading (https://github.com/open-data/ckanext-xloader/blob/567584b1fbb82987da662e6fde8fa4054d204abf/ckanext/xloader/plugin.py#L110-L112) and then specifying in ckanext-validation to only call xloader if the validation is a success: https://github.com/open-data/ckanext-validation/blob/ee70c9b3a1606c26fd3289a9ec12c32cb5800de7/ckanext/validation/jobs.py#L108C38-L115 |
Yeah, we are using async for Validation, so the Resources get created no matter what so we never came across this Xloader error. And then, yeah we disabled the default xloader submission code entirely, and then we manually call that xloader submit action in the validation extension. I have allotted some time for myself to make this into an upstream contribution on the Xloader and Datapusher extensions. Something like |
Update: I have wrapped the
|
There is a bug in this extension when creating a new resource that contains an invalid structure (e.g. duplicate column names).
After clicking on "Add", the user is directed to a non-existent page (
dataset/dataset-page-name/resource/new
) with a 404 error:What should happen
After clicking "Add", if the validation status is not "success":
The text was updated successfully, but these errors were encountered: