Skip to content

[S3] More comprehensive error handling #2451

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

npow
Copy link
Contributor

@npow npow commented Jun 11, 2025

  1. Improved error handling by ensuring fatal exceptions like ExpiredToken are no longer retried.
  2. Performed some code refactoring for better clarity and maintainability.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances S3 error handling by introducing a dedicated 400 “invalid request” code and refactoring the client‐error normalization to use categorized error sets.

  • Added ERROR_INVALID_REQUEST constant and mapped it in op_info, handle_client_error, get_info, and list_prefix.
  • Refactored normalize_client_error to classify errors into permission, not found, range, transient, and fatal groups.
  • Updated higher‐level S3 operations to raise or propagate the new 400 error.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
metaflow/plugins/datatools/s3/s3op.py Added ERROR_INVALID_REQUEST, categorized error sets, and 400 mappings
metaflow/plugins/datatools/s3/s3.py Raised new 400 error in _head and _one_boto_op
Comments suppressed due to low confidence (2)

metaflow/plugins/datatools/s3/s3op.py:261

  • [nitpick] There are no unit tests verifying the new 400 (ERROR_INVALID_REQUEST) branch in op_info. Consider adding tests to cover this error mapping to avoid regressions.
elif error_code == 400:

metaflow/plugins/datatools/s3/s3.py:856

  • [nitpick] Raising the generic MetaflowS3Exception for invalid requests may obscure this specific scenario. Consider defining a distinct exception class (e.g., MetaflowS3InvalidRequest) for clearer error handling.
elif info["error"] == s3op.ERROR_INVALID_REQUEST:

romain-intel
romain-intel previously approved these changes Jun 11, 2025
Copy link
Contributor

@romain-intel romain-intel left a comment

Choose a reason for hiding this comment

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

Minor nits but lgtm.

return 503
pass

# Permission or access-related errors → 403 Forbidden
Copy link
Contributor

Choose a reason for hiding this comment

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

If you got these errors from a specific location (doc), could you add a link to it so we can periodically check if they haven't changed. This is much cleaner though so hopefully it will help going forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added links and some more error codes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i think i got them all now

@madhur-ob
Copy link
Collaborator

@npow adding the label to run S3 tests against minIO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants