There seems to be a bug within the API validation that causes a server error 500 when feeding identical values such as affiliations or languages. This could potentially apply to all array values.
Steps to Reproduce
feed this JSON body to endpoint:
POST {{baseURL}}/api/records
<!--
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 2552, in __call__
return self.wsgi_app(environ, start_response)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/werkzeug/middleware/proxy_fix.py", line 187, in __call__
return self.app(environ, start_response)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/werkzeug/middleware/dispatcher.py", line 78, in __call__
return app(environ, start_response)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 2552, in __call__
return self.wsgi_app(environ, start_response)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/werkzeug/middleware/proxy_fix.py", line 187, in __call__
return self.app(environ, start_response)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 2532, in wsgi_app
response = self.handle_exception(e)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 2529, in wsgi_app
response = self.full_dispatch_request()
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask_resources/resources.py", line 65, in view
return view_meth()
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask_resources/content_negotiation.py", line 116, in inner_content_negotiation
return f(*args, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask_resources/parsers/decorators.py", line 51, in inner
return f(self, *args, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask_resources/parsers/decorators.py", line 90, in inner
return f(self, *args, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/flask_resources/responses.py", line 39, in inner
res = f(*args, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records_resources/resources/records/resource.py", line 93, in create
item = self.service.create(
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 324, in inner
res = f(self, *args, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_drafts_resources/services/records/service.py", line 265, in create
res = self._create(
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 328, in inner
return f(self, *args, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records_resources/services/records/service.py", line 350, in _create
uow.register(RecordCommitOp(record, self.indexer))
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 297, in register
op.on_register(self)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 150, in on_register
self._record.commit()
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records/api.py", line 453, in commit
json = self._validate(format_checker=format_checker, validator=validator)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records/api.py", line 193, in _validate
_records_state.validate(
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/invenio_records/ext.py", line 67, in validate
return validate(data, schema, cls=validator_cls, resolver=resolver, **kwargs)
File "/home/user/.pyenv/versions/3.9.16/envs/api-test/lib/python3.9/site-packages/jsonschema/validators.py", line 1121, in validate
raise error
jsonschema.exceptions.ValidationError: [{'name': 'KTH [177] (EES'}, {'name': 'KTH [177] (EES'}] has non-unique elements
Failed validating 'uniqueItems' in schema['properties']['metadata']['properties']['creators']['items']['properties']['affiliations']:
{'items': {'$ref': '#/affiliation'},
'type': 'array',
'uniqueItems': True}
On instance['metadata']['creators'][0]['affiliations']:
[{'name': 'KTH [177] (EES'}, {'name': 'KTH [177] (EES'}]
-->
slint The uniqueItems validation in the JSONSchema (i.e. when saving the record JSON to the DB) but not in the Marshmallow schema when loading the field.
Package version (if known): 12 b
Describe the bug
There seems to be a bug within the API validation that causes a server error 500 when feeding identical values such as affiliations or languages. This could potentially apply to all array values.
Steps to Reproduce
{{baseURL}}/api/records
Expected behavior
Normal validation error
Screenshots (if applicable)