test(bedrock): lock in legible non-JSON gateway error surfacing (PC-4775)#98
Open
cotovanu-cristian wants to merge 1 commit into
Open
test(bedrock): lock in legible non-JSON gateway error surfacing (PC-4775)#98cotovanu-cristian wants to merge 1 commit into
cotovanu-cristian wants to merge 1 commit into
Conversation
…775) The core fix already landed in #95 (raise_for_status before .json() on the converse and streaming paths, 2026-06-23), which post-dates the PC-4775 failing job's runtime 195.1.0. No production code changes here. #95's tests only exercised a plain httpx.Client with a JSON error body and asserted a bare httpx.HTTPStatusError. They did not cover the actual incident: a non-2xx HTML / non-JSON body through the patch_raise_for_status-wrapped client that production uses. Without the guard, that body crashed converse with a JSONDecodeError and the streaming path with a botocore ChecksumMismatch. Add regression tests that drive converse and converse_stream through a patched client returning a 403 HTML body, asserting a typed UiPathPermissionDeniedError carrying status 403 and the body excerpt instead of an opaque error. A mutation check (removing the raise_for_status guards) confirms both tests fail. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
No production code change. This PR adds the regression coverage that PC-4775 needs — it locks in the legible-error behavior for a non-2xx HTML / non-JSON gateway body, on both
converseandconverse_stream.The core fix already landed in #95 ("fix(bedrock): raise_for_status in WrappedBotoClient so gateway errors surface", merged 2026-06-23), which added
response.raise_for_status()before.json(). That commit post-dates the PC-4775 failing job (runtime195.1.0), which is why the job hit the old unconditional.json()and crashed with an opaquejson.decoder.JSONDecodeError.Why this PR exists
#95's tests only exercised a plain
httpx.Clientwith a JSON error body and asserted a barehttpx.HTTPStatusError. They did not cover the actual PC-4775 scenario:403 <!DOCTYPE html>), andpatch_raise_for_status-wrapped client that production uses (UiPathHttpxClient).So a regression of the legible-error behavior would have gone uncaught.
What the tests guard
Through the patched client, a 403 HTML body now surfaces as a typed
UiPathPermissionDeniedError(aUiPathAPIError) carrying:status_code == 403, anderror.body),instead of an opaque
JSONDecodeError(converse) orbotocore.eventstream.ChecksumMismatch(streaming).Mutation-verified: removing the
raise_for_status()guards fromutils.pymakes both new tests fail (converse → no raise; stream →ChecksumMismatch), confirming they genuinely lock in the fix. With the guards intact, all 8 tests in the file pass.Validation
uv run ruff check— passuv run ruff format --check— passuv run pyright tests/.../test_wrapped_boto_client.py— 0 errorsuv run pytest tests/.../test_wrapped_boto_client.py— 8 passedclient_settingsfixture errors intest_unit.py/test_integration.pyreproduce on cleanmainand require UiPath env; not touched here.)Related
🤖 Generated with Claude Code