Skip to content

refactor: error handling - #471

Open
alexanto wants to merge 1 commit into
refactor/extract-aiohttp-transportfrom
refactor/error-contract
Open

alexanto wants to merge 1 commit into
refactor/extract-aiohttp-transportfrom
refactor/error-contract

Conversation

@alexanto

@alexanto alexanto commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

makes the API clients' error handling library-neutral, so a transport built on any HTTP library behaves the same: any exception from transport.execute() is a failed request and it gets logged, and the client keeps running

because of this a malformed header no longer crashes anything, so I added a validate headers check

@alexanto
alexanto changed the base branch from main to refactor/extract-aiohttp-transport November 4, 2026 14:35
@alexanto
alexanto added this pull request to stack #468 November 4, 2026 15:06
@gastonfournier gastonfournier moved this from New to In Progress in Issues and PRs Nov 5, 2026
@alexanto
alexanto force-pushed the refactor/error-contract branch from a6a60cc to 2163219 Compare November 5, 2026 13:28
@alexanto
alexanto requested review from ppicom and a balanced review from Copilot November 6, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Header validation incorrectly permits None for app_name, instance_id, and connection_id, bypassing the documented constructor TypeError and deferring handling to the HTTP library.

1 open issue
What changed in this PR

This PR makes API request error handling independent of the HTTP library, aligning the synchronous and asynchronous clients.

Changes:

  • Treat transport exceptions during registration and metrics submission as failed requests while preserving payload serialization errors.
  • Validate header values during configuration and remove redundant initialization-time URL checks.
  • Update regression tests and migration documentation for the revised behavior.
File Description
v7_MIGRATION_GUIDE.md Documents header validation and trailing-newline handling.
UnleashClient/​utils.py Adds header-value validation.
UnleashClient/​config.py Validates configured header values at construction.
UnleashClient/​clients/​unleash_client.py Removes redundant URL validation during initialization.
UnleashClient/​clients/​async_unleash_client.py Removes redundant URL validation and outdated exception documentation.
UnleashClient/​_unleash_api_client.py Handles transport exceptions without requests-specific exception types.
UnleashClient/​_async_unleash_api_client.py Broadens transport error handling while preserving cancellation.
tests/​unit_tests/​test_utils.py Tests header validation and secret-safe errors.
tests/​unit_tests/​test_unleash_api_client.py Tests transport failures and serialization-error propagation.
tests/​unit_tests/​test_config.py Tests constructor header validation.
tests/​unit_tests/​test_async_unleash_api_client.py Tests transport failures, closed transports, and serialization errors.
CHANGELOG.md Records validation and registration-error behavior changes.

Review effort: Balanced

Comment thread UnleashClient/config.py
("unleash-instanceid", self.identity.instance_id),
("unleash-connection-id", self.connection_id),
):
if value is not None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is hardly a regression and there are defaults for those values in case of None, so I dont this this makes much sense

This branch has not been deployed

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants