Skip to content

Review error handling in the CLI#28

Merged
simleo merged 3 commits intocrs4:mainfrom
simleo:review_cli_errors
Nov 26, 2025
Merged

Review error handling in the CLI#28
simleo merged 3 commits intocrs4:mainfrom
simleo:review_cli_errors

Conversation

@simleo
Copy link
Member

@simleo simleo commented Nov 26, 2025

CLI command implementations used try-except blocks that swallowed part of the information contained in the exceptions raised by the API. This PR reviews all commands so that, in case of errors, they raise the relevant HTTP exception, and use the detail part of the response to log an error message containing more specific information. In some cases, the HTTP status code used by the API was changed to be more accurate (e.g., 404 to 422 when a crate does not contain ro-crate-metadata.json).

Example:

Before:

$ provstor -l INFO load /tmp/empty/
INFO:root:Crate path: /tmp/provstor_d97p5595/empty.zip
INFO:root:Uploading crate to http://localhost:8000/upload/crate/
Traceback (most recent call last):
[...]
RuntimeError: API returned status code 404: Not Found

After:

$ provstor -l INFO load /tmp/empty/
INFO:root:Crate path: /tmp/provstor_rbw7skj1/empty.zip
INFO:root:Uploading crate to http://localhost:8000/upload/crate/
ERROR:root:ro-crate-metadata.json not found in the zip file
[...]
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Content for url: http://localhost:8000/upload/crate/

@simleo
Copy link
Member Author

simleo commented Nov 26, 2025

7152a85 was necessary because minio-py introduced breaking changes in version 7.2.19 -- now the Minio constructor and several methods require keyword arguments. Looks like this is not documented yet, so I had to rely on minio/minio-py@7.2.18...7.2.19

See scikit-hep/uproot5#1527 for more info

@simleo simleo merged commit 4a95110 into crs4:main Nov 26, 2025
2 checks passed
@simleo simleo deleted the review_cli_errors branch November 26, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant