ckanext-validation icon indicating copy to clipboard operation
ckanext-validation copied to clipboard

Fix Upload Field Condition

Open JVickery-TBS opened this issue 1 year ago • 4 comments

fix(dev): FieldStorage support;

  • Added condition to check for file attribute from FieldStorage object for ckanapi support.

CKANAPI uses cgi.FieldStorage (https://github.com/ckan/ckanapi/blob/master/ckanapi/localckan.py#L67) as to not require a lot of dependencies. Related issue on cgi.FieldStorage: https://bugs.python.org/issue19097

To support all py versions and cgi dependency versions, just checking for the file attribute might be good enough?

JVickery-TBS avatar Feb 14 '24 18:02 JVickery-TBS

We've seen situations before where the FileStorage object exists but is blank, and it's necessary to further check that it has a truthy filename.

ThrawnCA avatar Feb 15 '24 03:02 ThrawnCA

@ThrawnCA reckon I should add the filename attribute condition after the new file one? Or just replace the new file condition with filename?

JVickery-TBS avatar Feb 15 '24 14:02 JVickery-TBS

Offhand I'm not sure whether testing file and testing filename are interchangeable.

ThrawnCA avatar Feb 15 '24 23:02 ThrawnCA

@ThrawnCA good enough for me! haha, I have added the filename condition in the case that the file attribute of a File like object is empty, but there is a filename. Should still get queued for validation and then the validation will fail and tell the user that their file is empty. This make sense to me

JVickery-TBS avatar Feb 16 '24 14:02 JVickery-TBS