ckan / ckan/ckanext-validation

bug with `is_url` ?

Open
#92 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
30
Forks
33
PR merge metrics
No merged PRs in 30d

Description

CKAN errors out at [line 4](https://github.com/frictionlessdata/ckanext-validation/blob/master/ckanext/validation/templates/scheming/form_snippets/resource_schema.html#L4) 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]` ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.