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

Validation errors during resource creation lead to wrong URLs #5152

Closed
amercader opened this issue Jan 10, 2020 · 0 comments · Fixed by #5153
Closed

Validation errors during resource creation lead to wrong URLs #5152

amercader opened this issue Jan 10, 2020 · 0 comments · Fixed by #5153
Assignees

Comments

@amercader
Copy link
Member

amercader commented Jan 10, 2020

This was hard to track as it doesn't happen in a standard CKAN install, as the default resource form doesn't have required fields.

If an extension implements custom validation in the resource schema, and there are errors returned in the form the File upload field will be set to the previously uploaded file name (ie a string).

When submitting, CKAN will interpret that like an external URL, and create a bogus http://<file_name> URL. There will be no errors returned so it's easier for users to assume that the file they first selected was successfully uploaded.

To reproduce:

  1. Modify the resource schema, eg adding the not_empty validator to description

  2. Go to the create resource page, select a file to upload, eg libraries.csv, leave the description empty and submit

  3. You get redirected to the form page, with the description error, and also with "libraries.csv" set on the File field:
    Screenshot_2020-01-10 Add resource - Test URLs 4 - CKAN(1)

  4. Submit the form. The resource is created, and has http://libraries.csv as URL.

The safest fix I can think of is resetting the upload field if there are validation errors. This will mean that users need to select the file again, but this is preferable to create a bad URL (we can not reset the field to the actual file previously selected because of browser security limitations). We can make this obvious to users with a message.

@amercader amercader self-assigned this Jan 10, 2020
amercader added a commit that referenced this issue Jan 10, 2020
…Error

Also add a custom error that we can use to show a warning in the
template that users need to resubmit the file
amercader added a commit that referenced this issue Jan 10, 2020
The previously selected File is lost and it's easy to miss it, so add a
little warning under the File button warning users to resubmit it
amercader added a commit that referenced this issue Jan 10, 2020
amercader added a commit that referenced this issue Jan 10, 2020
Otherwise when using errors it is shown on the error summary on top when
using scheming
amercader added a commit that referenced this issue Jan 13, 2020
smotornyuk added a commit that referenced this issue Jan 16, 2020
[#5152] Fix wrong resource URL after ValidationErrors
amercader added a commit that referenced this issue Apr 3, 2020
fostermh pushed a commit to cioos-siooc/ckan that referenced this issue Sep 10, 2021
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.

1 participant