You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an IDatasetForm plugin is active (see #396) then when showing a dataset with no resource, the validation done in package_show strips the resources key from the dict. Templates that try to read this key then crash, causing lots of pages to 500.
We could change validate() to not strip out keys that have empty lists as their values.
Or we could fix the templates not to crash on dataset dicts with no resources key.
The text was updated successfully, but these errors were encountered:
Option 1: Fix the templates to not crash when the package_dict has no resources. I could fix the legacy templates, and that would make the tests pass, but the new templates may also be crashing, and we don't have any tests for those. There could be dozens of bugs like this, where validate() strips some key from a dict and then a template crashes as a result, and we won't find them because (a) we don't have tests for the new templates and (b) these bugs are only triggered when an IDatasetForm plugin is active and one isn't normally active when we run the tests or do QA.
So that leaves Option 2: Fix validate() to never strip keys from data dicts when those keys have empty values. There is actually already an option in CKAN, fix_partial_updates, that seems to do this, but it's turned off by default. We could make it the default behaviour but it probably breaks some tests (I will test and see..)
Longer term I think we need CKAN to do validation using form_to_db_package_schema() and db_to_form_package_schema() even when there's no IDatasetForm plugin active, just so that we'll catch bugs like this when running the tests and QAing, but that is a different issue.
The tests all pass if you run them with fix_partial_updates on, but I think the way fix_partial_updates is implemented it may short-circuit some schema validators that you wouldn't want it to, so may need to fix it a different way
I'm assuming since all the core tests are passing with an IDatasetForm active now that this is fixed even if I apparently didn't autoclose it in a commit message. Closing now
If an IDatasetForm plugin is active (see #396) then when showing a dataset with no resource, the validation done in
package_show
strips the resources key from the dict. Templates that try to read this key then crash, causing lots of pages to 500.We could change
validate()
to not strip out keys that have empty lists as their values.Or we could fix the templates not to crash on dataset dicts with no resources key.
The text was updated successfully, but these errors were encountered: