inveniosoftware / invenio-app-rdm

Turn-key research data management platform.
https://inveniordm.docs.cern.ch
MIT License
108 stars 147 forks source link

Unresolvable JSON pointer: 'user', when creating a new draft. #2195

Open RoHei opened 1 year ago

RoHei commented 1 year ago

Package version (if known): 2.2

Describe the bug

I deployed InvenioRDM using Docker container according to the docs by running: invenio-cli containers start --lock --setup. All containers start and the page is displayed on my virtual machine nicely (Ubuntu Server 20.04. LTS). I can also create a user and generate an API key.

However, when I want to create a new record draft and click on "Save draft" or "Publish", the page returns:

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

As a consequence, the draft is not created/saved. However, when looking up in the docker container, I can identify the following error message that seems to be highly related as it occurrs after clicking the button:

[2023-04-17 13:12:18,791] ERROR in app: Exception on /records [POST]
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 1105, in resolve_fragment
    document = document[part]
KeyError: 'user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/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 "/usr/lib/python3.9/site-packages/flask_resources/resources.py", line 65, in view
    return view_meth()
  File "/usr/lib/python3.9/site-packages/flask_resources/content_negotiation.py", line 116, in inner_content_negotiation
    return f(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/flask_resources/parsers/decorators.py", line 51, in inner
    return f(self, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/flask_resources/parsers/decorators.py", line 90, in inner
    return f(self, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/flask_resources/responses.py", line 39, in inner
    res = f(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/invenio_records_resources/resources/records/resource.py", line 90, in create
    item = self.service.create(
  File "/usr/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 324, in inner
    res = f(self, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/invenio_drafts_resources/services/records/service.py", line 237, in create
    uow.register(RecordCommitOp(res._record.parent))
  File "/usr/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 297, in register
    op.on_register(self)
  File "/usr/lib/python3.9/site-packages/invenio_records_resources/services/uow.py", line 150, in on_register
    self._record.commit()
  File "/usr/lib/python3.9/site-packages/invenio_records/api.py", line 453, in commit
    json = self._validate(format_checker=format_checker, validator=validator)
  File "/usr/lib/python3.9/site-packages/invenio_records/api.py", line 193, in _validate
    _records_state.validate(
  File "/usr/lib/python3.9/site-packages/invenio_records/ext.py", line 67, in validate
    return validate(data, schema, cls=validator_cls, resolver=resolver, **kwargs)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 1258, in validate
    error = exceptions.best_match(validator.iter_errors(instance))
  File "/usr/lib/python3.9/site-packages/jsonschema/exceptions.py", line 414, in best_match
    best = next(errors, None)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 330, in iter_errors
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_validators.py", line 284, in ref
    yield from validator._validate_reference(ref=ref, instance=instance)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 375, in descend
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_validators.py", line 305, in properties
    yield from validator.descend(
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 375, in descend
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_validators.py", line 305, in properties
    yield from validator.descend(
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 375, in descend
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_legacy_validators.py", line 115, in items_draft6_draft7_draft201909
    yield from validator.descend(item, items, path=index)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 375, in descend
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_validators.py", line 284, in ref
    yield from validator._validate_reference(ref=ref, instance=instance)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 375, in descend
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_validators.py", line 356, in oneOf
    errs = list(validator.descend(instance, subschema, schema_path=index))
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 375, in descend
    for error in errors:
  File "/usr/lib/python3.9/site-packages/jsonschema/_validators.py", line 284, in ref
    yield from validator._validate_reference(ref=ref, instance=instance)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 416, in _validate_reference
    scope, resolved = resolve(ref)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 1039, in resolve
    return url, self._remote_cache(url)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 1057, in resolve_from_url
    return self.resolve_fragment(document, fragment)
  File "/usr/lib/python3.9/site-packages/jsonschema/validators.py", line 1107, in resolve_fragment
    raise exceptions._RefResolutionError(
jsonschema.exceptions._RefResolutionError: Unresolvable JSON pointer: 'user'

However, I also logged in to the SQL-Database on the server but there the current user exists, so I would suppose that it is not an database-lookup issue. Also it does make no difference, if I enter creators in the template as the error always occurs.

Steps to Reproduce

  1. Start Invenio in Docker-Mode on a local Ubuntu Server machine
  2. Log-in to the UI and edit a new record
  3. Click on "Save Draft"

Expected behavior

Expecting that the record would be saved.

Additional Information

The configuration file was only changed slightly. One section affects the allowed servers and the others the authentication, where I set: SECURITY_LOGIN_WITHOUT_CONFIRMATION = False, but I don't think that this is related.

kpsherva commented 1 year ago

hello @RoHei ! thank you for reporting this. To give us a bit more details about the issue, could you share with us the version of jsonchema package you are using inside the container ? (you need to run pip show jsonschema) inside the container or check the version in your pipfile-lock.json. Did you run the installation with allow_prereleases = True (in your Pipfile) ?

RoHei commented 1 year ago

Thanks for the quick reply. In the Pipfile.lock I see this version.

        "jsonschema": {
            "hashes": [
                "sha256:74655a97c41753163c195ac342ceb91168d6b719b123ebc1bbfa3cff6d103481",
                "sha256:dae26a6aaf4b278b1d1aafd892aee9f16604971497a03c566c365e9ea4dc2c33"
            ],
            "markers": "python_version >= '3.8'",
            "version": "==4.18.0a3"
        },

Furthermore, in my Pipifile, allow_prepreleases is set to False.

kpsherva commented 1 year ago

Thanks for the quick reply. In the Pipfile.lock I see this version.

        "jsonschema": {
            "hashes": [
                "sha256:74655a97c41753163c195ac342ceb91168d6b719b123ebc1bbfa3cff6d103481",
                "sha256:dae26a6aaf4b278b1d1aafd892aee9f16604971497a03c566c365e9ea4dc2c33"
            ],
            "markers": "python_version >= '3.8'",
            "version": "==4.18.0a3"
        },

Furthermore, in my Pipifile, allow_prepreleases is set to False.

there is something wrong with dependency builder in your environment, because as you see the alpha version (pre release) of jsonschema was installed (despite not allowing pre-releases in your pipfile), and this alpha version is known to contain breaking changes. If you make sure you have the stable release of jsonschema dependency installed (4.17.0), the error should not appear.

github-actions[bot] commented 1 year ago

This issue was automatically marked as stale.