ckan / ckan/ckanext-validation

"TypeError: expected string or buffer" when Validation Options are set in config file but not provided in the resource field

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

Description

# Overview

As explained in the [Documentation](https://github.com/frictionlessdata/ckanext-validation#formats-to-validate) I set up a default value for the validation options in the configuration file.

I try to add a resource not providing any input in the resource field for validation options, and this leads to a Server error.

![image](https://user-images.githubusercontent.com/31211012/66835337-a6bf5780-ef5f-11e9-91c6-51b252e2a817.png)

The Server error is "TypeError: expected string or buffer" generated from the following [line of code](https://github.com/frictionlessdata/ckanext-validation/blob/master/ckanext/validation/validators.py#L62).

So this should take into account the case where the value is null.

I've added this as a solution:

`

if value:

provided_options = json.loads(value)

default_options.update(provided_options)
`

This should solve the issue. Should I submit a PR?

---

Please preserve this line to notify @amercader (maintainer of this repository)

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.