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

bug with is_url ? #92

Open
KatiRG opened this issue Oct 23, 2023 · 3 comments
Open

bug with is_url ? #92

KatiRG opened this issue Oct 23, 2023 · 3 comments

Comments

@KatiRG
Copy link

KatiRG commented Oct 23, 2023

CKAN errors out at line 4 of resource_schema.html if I have uploaded a JSON file containing a schema. The error is:

File "/usr/lib/ckan/default/src/ckanext-ontario_theme/ckanext/ontario_theme/templates/internal/scheming/form_snippets/resource_schema.html", line 7, in top-level template code
    {% set is_url = value and value[4:]|lower == 'http' %}
TypeError: unhashable type: 'slice'

The JSON file contains the following schema object:

{
    "fields": [
        {
            "name": "rule",
            "type": "string"
        },
        {
            "name": "integercol",
            "type": "number"
        }
    ]
}

and this object gets assigned to the value in line 4.

The line 4 checks if the schema is URL-based, but in this case, value is the above object, therefore value[4:] is invalid. Also, assuming value = http://someaddress, shouldn't the slice be value[:4] ?

@ThrawnCA
Copy link
Contributor

That sounds like an error in ckanext-ontario_theme rather than ckanext-validation.

@KatiRG
Copy link
Author

KatiRG commented Oct 24, 2023

@ThrawnCA I tested with core CKAN and got the same error with slice.

@KatiRG
Copy link
Author

KatiRG commented Oct 24, 2023

To avoid the error I have to set something like this in resource_schema.html:

  {# % set is_url = value and value[4:]|lower == 'http' % #}
  {# % set is_json = not is_url and value % #}
  {% set is_url = 'http' in value %}
  {% set is_json = not is_url %}

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

2 participants