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

json Validator Fails when License is included #161

Open
4 tasks
shlake opened this issue Nov 2, 2023 · 2 comments
Open
4 tasks

json Validator Fails when License is included #161

shlake opened this issue Nov 2, 2023 · 2 comments
Labels
status:incoming Newly created issue to be forwarded type:bug Something isn't working

Comments

@shlake
Copy link

shlake commented Nov 2, 2023

Bug report

dataset-finch1.json

When including license information in a dataset json file (see the above attached file), the file does not validate.

1. Describe your environment

  • OS: NAME, VERSION, 64/32bit MacOS 13.4.1, 64 bit
  • pyDataverse: VERSION. 0.3.1
  • Python: VERSION python3.9
  • Dataverse: VERSION 5.14

2. Actual behaviour:

When reading in a dataset json file ds.from_json(read_file(ds_filename)) (the one attached to this issue), I get the following errors:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sah/Library/Python/3.9/lib/python/site-packages/pyDataverse/models.py", line 855, in from_json
    validate_data(json_dict, filename_schema, file_format="json")
  File "/Users/sah/Library/Python/3.9/lib/python/site-packages/pyDataverse/utils.py", line 451, in validate_data
    validate(instance=data, schema=read_json(filename_schema))
  File "/Users/sah/Library/Python/3.9/lib/python/site-packages/jsonschema/validators.py", line 1302, in validate
    raise error
jsonschema.exceptions.ValidationError: {'name': 'CC0 1.0', 'uri': 'http://creativecommons.org/publicdomain/zero/1.0'} is not of type 'string'

Failed validating 'type' in schema['properties']['datasetVersion']['properties']['license']:
    {'$id': '#/properties/datasetVersion/properties/license',
     'type': 'string'}

On instance['datasetVersion']['license']:
    {'name': 'CC0 1.0',
     'uri': 'http://creativecommons.org/publicdomain/zero/1.0'}

3. Expected behaviour:

This file does successfully create a dataset with the correct license when using the API via command line (curl). This command works:

curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/dataverses/$PARENT/datasets" --upload-file dataset-finch1.json -H 'Content-type:application/json

@shlake shlake added status:incoming Newly created issue to be forwarded type:bug Something isn't working labels Nov 2, 2023
@pdurbin
Copy link
Member

pdurbin commented Nov 2, 2023

@pdurbin
Copy link
Member

pdurbin commented Nov 2, 2023

Oh and on a related note, you and @JR-1991 might be interested in the new JSON Schema in this issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:incoming Newly created issue to be forwarded type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants