Skip to content

Name the transport error when httpx gives no message - #58

Merged
glenn-jocher merged 1 commit into
mainfrom
connection-error-reason
Sep 30, 2026
Merged

glenn-jocher merged 1 commit into
mainfrom
connection-error-reason

Conversation

@glenn-jocher

@glenn-jocher glenn-jocher commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Generated Python clients wrap transport failures as APIConnectionError(str(error)). Some httpx errors have an empty message, most notably async timeouts (anyio raises a bare TimeoutError, so httpx.ReadTimeout has an empty string). Async SDK users then got APIConnectionError(''), and CLIs built on the SDK printed a reason with nothing after the colon.

The generated client now falls back to the httpx exception class name (str(error) or type(error).__name__), so an async read timeout reports ReadTimeout. Non-empty messages are unchanged, and the original exception is still chained as __cause__.

Validation

  • bun run generate, typecheck, lint, knip, test (20 pass), and build all pass.
  • Regenerated a real consumer package and ran it against a server that accepts connections but never responds, with timeout=0.3 and max_retries=0. The async client raised APIConnectionError('') before this change and APIConnectionError('ReadTimeout') after it. The sync client still raises 'timed out'.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

The generated Python client now uses the httpx exception class name when a transport error has no message, so empty-message failures have a readable error reason.

📊 Key Changes

  • Falls back from str(error) to type(error).__name__ when creating APIConnectionError.
  • Leaves non-empty error messages unchanged and continues chaining the original exception as __cause__.

🎯 Purpose & Impact

  • Async read timeouts with empty messages now report ReadTimeout instead of an empty reason; the PR validation also confirms the sync timeout still reports timed out.

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working fixed Bug has been resolved labels Sep 30, 2026
@UltralyticsAssistant

Copy link
Copy Markdown
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/openapi 🚀 PR! This automated message confirms your contribution was received, and an Ultralytics engineer will assist with the review. To ensure a seamless integration of your work, please review the following checklist:

  • ✅ Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • ✅ Synchronize with Source: Confirm your PR is synchronized with the ultralytics/openapi main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • ✅ Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • ✅ Update Documentation: Update the relevant documentation for any new or modified features.
  • ✅ Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • ✅ Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • ✅ Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

@UltralyticsAssistant UltralyticsAssistant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔍 PR Review

Made with ❤️ by Ultralytics Actions

Reviewed the Python transport-error formatting change. The fallback preserves non-empty messages and exception chaining while providing a useful name for empty messages. LGTM; no issues found.

@glenn-jocher
glenn-jocher merged commit 89513ec into main Sep 30, 2026
7 checks passed
@glenn-jocher
glenn-jocher deleted the connection-error-reason branch September 30, 2026 16:23
@UltralyticsAssistant

Copy link
Copy Markdown
Member

🎉 PR #58 has been merged—thank you, @glenn-jocher!

“Well done is better than well said.” — Benjamin Franklin

This focused change gives empty-message transport failures a clear reason, such as ReadTimeout, while preserving existing messages and exception chaining.

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

Labels

bug Something isn't working fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants