Skip to content

Conversation

tomeksabala
Copy link

I have encountered this bug while trying to call action resource_update with the field:

'last_modified': '2021-07-02T07:11:03.519Z'

which results in:

{
    "success": false,
    "error": {
        "last_modified": [
            "Date format incorrect"
        ],
        "__type": "Validation Error"
    }
}

I get success behavior if I remove the tz info from date string "Z".

To easily demonstrate the behavior I've created a failing test case scenario.

=================================== FAILURES ===================================
____________ TestDateTimes.test_datetime_with_tz_field_in_resource _____________

self = <ckanext.scheming.tests.test_validation.TestDateTimes object at 0x7f2802486650>

    def test_datetime_with_tz_field_in_resource(self):
        lc = LocalCKAN()
        lc.action.package_create(
            type="test-schema",
            name="derf_datetime_2",
            resources=[
                {
                    "url": "http://example.com/camel.txt",
                    "camels_in_photo": 2,
>                   "datetime": "2015-01-01T12:35:00Z",
                }
            ],
        )

/usr/lib/adx/ckanext-scheming/ckanext/scheming/tests/test_validation.py:324: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../local/lib/python2.7/site-packages/ckanapi/common.py:51: in action
    return self._ckan.call_action(name, data_dict=kwargs)
../../local/lib/python2.7/site-packages/ckanapi/localckan.py:71: in call_action
    return self._get_action(action)(context, data_dict)
ckan/logic/__init__.py:477: in wrapped
    result = _action(context, data_dict, **kw)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

context = {'__auth_audit': [], '__auth_user_obj_checked': True, 'auth_user_obj': <User id=73ac7c2b-f39a-4d49-9733-28fb38f95fb1 n...ne plugin_extras=None>, 'model': <module 'ckan.model' from '/usr/lib/ckan/venv/src/ckan/ckan/model/__init__.pyc'>, ...}
data_dict = {'name': 'derf_datetime_2', 'resources': [{'camels_in_photo': 2, 'datetime': '2015-01-01T12:35:00Z', 'url': 'http://example.com/camel.txt'}], 'type': 'test-schema'}

    def package_create(context, data_dict):
[....]
            model.Session.rollback()
>           raise ValidationError(errors)
E           ValidationError: None - {'resources': [{u'datetime': [u'Date format incorrect']}]}

ckan/logic/action/create.py:182: ValidationError
==================== 1 failed, 148 passed in 64.71 seconds =====================
Command not successful. Returned 1
Tests not successful. Returned: 1

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

Successfully merging this pull request may close these issues.

1 participant