Page MenuHomeSoftware Heritage

deposit.cli: Fix service document error when failing to retrieve it
ClosedPublic

Authored by ardumont on Mar 22 2021, 5:46 PM.

Details

Summary

Prior to this, failing to retrieve the collection (wrong credential for example)
would end up with yet another unrelated parsing error.

[1]

swh deposit metadata-only --url http://localhost:5080/deposit \
  --username test \
  --password test2 \
  --metadata ../deposit-swh.update-metadata.xml --format json
Traceback (most recent call last):
  File "/home/tony/.virtualenvs/swh/bin/swh", line 33, in <module>
    sys.exit(load_entry_point('swh.core', 'console_scripts', 'swh')())
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-core/swh/core/cli/__init__.py", line 185, in main
    return swh(auto_envvar_prefix="SWH")
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/tony/.virtualenvs/swh/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-deposit/swh/deposit/cli/client.py", line 570, in metadata_only
    collection = _collection(client)
  File "/home/tony/work/inria/repo/swh/swh-environment/swh-deposit/swh/deposit/cli/client.py", line 145, in _collection
    msg = sd_content["error"]["sword:summary"]
KeyError: 'sword:summary'
Test Plan

one test added

Diff Detail

Repository
rDDEP Push deposit
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build has FAILED

Patch application report for D5300 (id=18986)

Could not rebase; Attempt merge onto 1c20fcc561...

Updating 1c20fcc5..e6daa59d
Fast-forward
 swh/deposit/cli/client.py                 |  3 ++-
 swh/deposit/client.py                     | 25 +++++++++++++------------
 swh/deposit/tests/cli/test_client.py      | 30 ++++++++++++++++++++++++++++--
 swh/deposit/tests/data/atom/error-cli.xml |  9 +++++++++
 4 files changed, 52 insertions(+), 15 deletions(-)
 create mode 100644 swh/deposit/tests/data/atom/error-cli.xml
Changes applied before test
commit e6daa59da5957d0f4614db5c615306a1ea77f83c
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Mar 22 17:45:11 2021 +0100

    deposit.cli: Fix service document error when failing to retrieve it

commit 026ca4ead098bd3ddb8b8440ca0a77f50651debb
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Mar 22 15:57:21 2021 +0100

    deposit.cli: Fix cli parsing issue when xml error is returned by server
    
    Prior to this commit, any error returned by the deposit server would end up a cascading
    KeyError.
    
    This commit fixes it.

Link to build: https://jenkins.softwareheritage.org/job/DDEP/job/tests-on-diff/587/
See console output for more information: https://jenkins.softwareheritage.org/job/DDEP/job/tests-on-diff/587/console

Harbormaster returned this revision to the author for changes because remote builds failed.Mar 22 2021, 5:49 PM
Harbormaster failed remote builds in B20063: Diff 18986!

Build is green

Patch application report for D5300 (id=18987)

Could not rebase; Attempt merge onto 1c20fcc561...

Updating 1c20fcc5..84ed18de
Fast-forward
 swh/deposit/cli/client.py                 |  3 ++-
 swh/deposit/client.py                     | 27 ++++++++++---------
 swh/deposit/tests/cli/test_client.py      | 45 +++++++++++++++++++++++++++++--
 swh/deposit/tests/data/atom/error-cli.xml |  9 +++++++
 4 files changed, 68 insertions(+), 16 deletions(-)
 create mode 100644 swh/deposit/tests/data/atom/error-cli.xml
Changes applied before test
commit 84ed18de25a6ad9f3c37ef7710ec765ab0257992
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Mar 22 17:45:11 2021 +0100

    deposit.cli: Fix service document error when failing to retrieve it

commit 026ca4ead098bd3ddb8b8440ca0a77f50651debb
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Mar 22 15:57:21 2021 +0100

    deposit.cli: Fix cli parsing issue when xml error is returned by server
    
    Prior to this commit, any error returned by the deposit server would end up a cascading
    KeyError.
    
    This commit fixes it.

See https://jenkins.softwareheritage.org/job/DDEP/job/tests-on-diff/588/ for more details.

ardumont edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Mar 22 2021, 6:20 PM