Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

@google-labs-jules google-labs-jules bot commented Dec 23, 2025

Improved error handling in google/auth/compute_engine/_metadata.py to provide more informative error messages when retries are exhausted.

The logic now handles two distinct failure modes:

  1. Connection Errors (Exceptions):

    • Exceptions caught during the request (e.g., connection refused) are stored in last_exception.
    • If the retry loop exhausts and last_exception is set, a TransportError is raised that chains the original exception. This preserves the stack trace and specific error type for debugging.
  2. Retryable HTTP Status Codes:

    • If a request completes but returns a retryable status code (e.g., 500, 503), last_exception is cleared (set to None).
    • If the retry loop exhausts due to repeated retryable status codes, a TransportError is raised that includes the response.status and the response body (error_details). This ensures the specific server error message is visible.

This addresses feedback from PR 1637 by ensuring that "Ran out of retries" scenarios provide the most relevant context: either the underlying exception or the final HTTP error response.


PR created automatically by Jules for task 6226991344715693997 started by @chalmerlowe

Distinguish between retry exhaustion due to exceptions and retry exhaustion due to retryable status codes.
- Use `last_exception` to track the most recent exception.
- Clear `last_exception` on successful response (even if status is retryable).
- Raise TransportError chained from `last_exception` if available.
- Otherwise raise TransportError with response status and details.
- Update tests to match new error format.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

google-labs-jules bot and others added 2 commits December 26, 2025 14:22
Distinguish between retry exhaustion due to exceptions and retry exhaustion due to retryable status codes.
- Use `last_exception` to track the most recent exception.
- Clear `last_exception` on successful response (even if status is retryable).
- Raise TransportError chained from `last_exception` if available.
- Otherwise raise TransportError with response status and details.
- Update tests to match new error format.
@chalmerlowe chalmerlowe self-assigned this Dec 26, 2025
@chalmerlowe chalmerlowe added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 26, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 26, 2025
@chalmerlowe chalmerlowe marked this pull request as ready for review December 26, 2025 16:21
@chalmerlowe chalmerlowe requested review from a team as code owners December 26, 2025 16:21
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