Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Id in Errors #884

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

EngHabu
Copy link

@EngHabu EngHabu commented Jun 17, 2024

Add RequestID and Http Status Code to the error object.

Signed-off-by: Haytham Abuelfutuh <[email protected]>
@martindurant
Copy link
Member

This is a reasonable idea, please let me know when you are finished. Note that moto (the CI backend) probably has a different idea of request ID compared to AWS S3, and of course there are several other S3 implementations (e.g., minio) that might have something different again.

@EngHabu
Copy link
Author

EngHabu commented Jun 17, 2024

Thank you for your quick comment, @martindurant.
Looks like moto uses the same s3 response structure for RequestId: https://github.com/getmoto/moto/blob/master/tests/test_s3/test_s3_metadata.py#L20-L25 (added here)

I don't seem to find request ids in minio responses (sad). Not in the body and nor in the response headers.
image
image

Signed-off-by: Haytham Abuelfutuh <[email protected]>
@EngHabu EngHabu marked this pull request as ready for review June 18, 2024 13:56
@EngHabu
Copy link
Author

EngHabu commented Jun 18, 2024

@martindurant mind taking a look?

@martindurant
Copy link
Member

This could use a test; any error on moto should have both the status and ID set (non-empty). I wonder whether instead of extending the message, we should add the information to the exception object, so it only shows up for those who want it. What do you think?

Signed-off-by: Haytham Abuelfutuh <[email protected]>
@EngHabu
Copy link
Author

EngHabu commented Jun 21, 2024

I briefly looked into that as well because I would like to be able to extract that information separately. But it uses the native OSError type and not sure how you feel about subclassing that?

@@ -98,7 +98,7 @@ def get_boto3_client():

# NB: we use the sync botocore client for setup
session = Session()
return session.create_client("s3", endpoint_url=endpoint_uri)
return session.create_client("s3", endpoint_url=endpoint_uri, region_name="us-east-1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

@martindurant
Copy link
Member

Sorry I let this drop.

But it uses the native OSError type and not sure how you feel about subclassing that?

Yes, that's totally since, since except matches subclasses.

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.

2 participants