BlueBrain / BlueBrain/nexus-python-sdk

improve error message for create_link method.

Open
#75 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I put a wrong media_type "directory" while calling create_link.
I would say it is not obvious to understand the issue.Here is the error I got:
[13:00:35]
OrderedDict([('@context', ['https://bluebrain.github.io/nexus/contexts/iam.json', 'https://bluebrain.github.io/nexus/contexts/resource.json']), ('@id', 'http://dev.nexus.ocp.bbp.epfl.ch/v1/permissions'),
('@type', 'Permissions'), ('permissions', ['acls/read', 'acls/write', 'events/read', 'files/write', 'organizations/create', 'organizations/read', 'organizations/write', 'permissions/read', 'permissions/write', 'projects/create', 'projects/read', 'projects/write', 'realms/read', 'realms/write', 'resolvers/write', 'resources/read', 'resources/write', 'schemas/write', 'storages/write', 'views/query', 'views/write']), ('_rev', 0), ('_createdAt', '1970-01-01T00:00:00Z'), ('_createdBy', 'http://dev.nexus.ocp.bbp.epfl.ch/v1/anonymous'), ('_updatedAt', '1970-01-01T00:00:00Z'), ('_updatedBy', 'http://dev.nexus.ocp.bbp.epfl.ch/v1/anonymous')])
Traceback (most recent call last):
File "test.py", line 32, in
result = nexus.files.create_link(org_label=ORG, project_label=PROJ, filename= 'circuit_renamed', filepath = 'courcol/circuit', media_type='directory', file_id='foobar')
File "/Users/courcol/DEV/nexus-sdk/nexus-python-sdk/nexussdk/files.py", line 139, in create_link
return http_put(request_path, body=payload, storage=storage_id)
File "/Users/courcol/DEV/nexus-sdk/nexus-python-sdk/nexussdk/utils/http.py", line 168, in http_put
response.raise_for_status()
File "/Users/courcol/DEV/nexus-sdk/venv/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the invalid media_type case shown in test.py and trace create_link in nexussdk/files.py around line 139 into http_put in nexussdk/utils/http.py around line 168. Determine where the current HTTP error loses useful context, then verify that the resulting message clearly identifies the invalid input and run the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.