Skip to content

refactor(sdk-python): hoist HTTPX network error names in exception converter#343

Closed
Gujiassh wants to merge 1 commit intoalibaba:mainfrom
Gujiassh:refactor/python-network-error-set
Closed

refactor(sdk-python): hoist HTTPX network error names in exception converter#343
Gujiassh wants to merge 1 commit intoalibaba:mainfrom
Gujiassh:refactor/python-network-error-set

Conversation

@Gujiassh
Copy link
Contributor

@Gujiassh Gujiassh commented Mar 5, 2026

Summary

  • move the static HTTPX network error names from _is_httpx_network_error into a module-level constant
  • reuse that constant for membership checks instead of constructing a tuple on every invocation
  • keep exception mapping behavior unchanged

Why

_is_httpx_network_error sits on the exception conversion path and can be called repeatedly under transient/network-failure conditions. Hoisting the constant removes repeated tuple construction and centralizes the canonical list of supported HTTPX network error names.

Testing

  • python3 -m py_compile sdks/sandbox/python/src/opensandbox/adapters/converter/exception_converter.py
  • python3 -m pytest tests/test_converters_and_error_handling.py -q

Compatibility

  • no API or behavior changes
  • same recognized error names, only storage location changed

@CLAassistant
Copy link

CLAassistant commented Mar 5, 2026

CLA assistant check
All committers have signed the CLA.

@Gujiassh
Copy link
Contributor Author

Gujiassh commented Mar 5, 2026

Maintainer note: this change stays intentionally behavior-preserving and scoped to a single refactor in the exception conversion path.\n\nIf useful, I can follow up with a separate PR that switches from string-name matching to direct exception-class checks and includes a small benchmark comparison.

@Pangjiping
Copy link
Collaborator

LGTM, efficient code refactoring! Please sign the CLA and @ninan-nn will review those changes. 😊

@Gujiassh
Copy link
Contributor Author

Gujiassh commented Mar 9, 2026

Thanks again — the CLA is signed now and the checks are all green on my side. @ninan-nn, when you have a moment, could you take a look?

@ninan-nn
Copy link
Collaborator

ninan-nn commented Mar 9, 2026

Duplicated with #376

@ninan-nn ninan-nn closed this Mar 9, 2026
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.

4 participants