Skip to content

feat(session): log Meraki X-Request-Id on 5xx responses (httpx forward-port of #420)#426

Open
TKIPisalegacycipher wants to merge 1 commit into
httpxfrom
forward-port/x-request-id-httpx
Open

feat(session): log Meraki X-Request-Id on 5xx responses (httpx forward-port of #420)#426
TKIPisalegacycipher wants to merge 1 commit into
httpxfrom
forward-port/x-request-id-httpx

Conversation

@TKIPisalegacycipher

Copy link
Copy Markdown
Collaborator

Forward-port of #420 to the httpx branch.

Logs the Meraki X-Request-Id response header on 5xx responses so it can be handed to Meraki for server-side log lookup. Included in the per-retry warning and, once retries are exhausted, logged at error level. When the header is absent, none is logged in its place.

#420 did not apply directly because the httpx branch refactored sessions into meraki/session/{sync,async_,base}.py. Manual re-port:

  • Sync: SessionBase._handle_server_error now includes the request id in its warning; new _log_server_error_exhausted helper logs at error level when retries == 0.
  • Async: inlined in the 5xx dispatch block (the async path does not use the helper).
  • Async unifies on APIError (no AsyncAPIError); tests target the new meraki/session/ paths and _client.request mocks, plus a new session_with_logger conftest fixture.

Tests: full sync + async session suites pass (163), ruff clean.

🤖 Generated with Claude Code

Forward-port of #420 to the httpx branch. The session refactor moved 5xx
handling into SessionBase._handle_server_error (sync) and the inline async
dispatch, so the warning now includes the X-Request-Id and a new
_log_server_error_exhausted helper logs it at error level once retries are
exhausted. Async unifies on APIError (no AsyncAPIError) and tests target the
new meraki/session/ paths and _client.request mocks.

When the header is absent, "none" is logged in its place.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant