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

crash when parsing custom validators #277

Open
ricardogsilva opened this issue Apr 14, 2022 · 0 comments
Open

crash when parsing custom validators #277

ricardogsilva opened this issue Apr 14, 2022 · 0 comments

Comments

@ricardogsilva
Copy link

ricardogsilva commented Apr 14, 2022

There is a bug in ckanext.spatial.harvesters.base.SpatialHarvester._get_validator()

for custom_validator in custom_validators:

This is a verbatim copy of the code that is currently in master:

# Add any custom validators from extensions
for plugin_with_validators in p.PluginImplementations(ISpatialHarvester):
    custom_validators = plugin_with_validators.get_validators()
    for custom_validator in custom_validators:
        if custom_validator not in all_validators:
            self._validator.add_validator(custom_validator)

In the above snippet, the custom_validators variable is a Python dictionary, as documented in the CKAN docs. The problem is that the nested for loop is iterating over the dictionary keys, which are strings, and then passes each item to self._validator.add_validator, which expects to receive a class instance instead - which by the way is also bugged, as current versions of CKAN allow using regular functions as validators.

I'm guessing this is something left behind from when CKAN moved to Flask from Pylons?

Unfortunately this is something that prevents using custom validators and customizing a harvester behavior at the same time in the same plugin class.

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

No branches or pull requests

1 participant