fix: keep the response body out of UiPathAPIError.__str__ [PC-5002] - #135
Merged
Merged
Conversation
The traceback module renders the final exception line with str(), so the relayed provider response body was copied verbatim into every printed stacktrace -- including the one shipped as AgentRun.Failed.ErrorTraceback -- regardless of what the consuming runtime chose to put in its own customer-facing error. The body is content of unknown sensitivity and may carry PII. The body now stays on the `body` attribute, unchanged, for callers that classify on it, and out of the serialized form. `__repr__` is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BnGx1AgzrA4Qq1bRrbvjyd
ionut-mihalache-uipath
requested review from
DragosBobolea,
cosminacho,
cristipufu,
dragosvelcea,
ionmincu,
radu-mocanu and
vldcmp-uipath
as code owners
September 7, 2026 20:30
ionut-mihalache-uipath
deployed
to
LLMGW_SETTINGS
September 7, 2026 20:31 — with
GitHub Actions
Active
tudormatei1
reviewed
Sep 8, 2026
| # ``self.body`` is deliberately absent. The traceback module renders the | ||
| # final exception line with str(), so anything here is copied verbatim | ||
| # into every printed stacktrace -- potentially including PII | ||
| return f"{self.__class__.__name__}: {self.message} (Status Code: {self.status_code})" |
Contributor
There was a problem hiding this comment.
is removing the whole body a valid solution to this PII vs traceability trade off? excluding the whole body might be removing too much info that would be helpful when debugging. maybe it might be better to try to isolate potential PII on specific body fields and exclude those. for instance for bad request we had this discussion so it might be nice to map out exactly on what fields PII bad request can appear (https://uipath-product.slack.com/archives/C05AANXHV9S/p1788178862719219)
Collaborator
Author
There was a problem hiding this comment.
given we don't know for sure which fields can contain PII then it's safer to ignore all of them.
tudormatei1
approved these changes
Sep 8, 2026
ionut-mihalache-uipath
deleted the
fix/pc-5002-api-error-str-omits-body
branch
September 9, 2026 10:47
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.
What changed
UiPathAPIError.__str__no longer appendsself.body.The
tracebackmodule renders the final exception line withstr(). That meant the relayed provider response body was copied verbatim into every printed stacktrace — including the one shipped asAgentRun.Failed.ErrorTraceback— regardless of what the consuming runtime chose to put in its own customer-facing error. The body is content of unknown sensitivity and may carry PII.The body stays on the
.bodyattribute, unchanged, for callers that classify on it.__repr__is unchanged.Before:
After:
Why
The body is not something the runtime can reason about before it reaches a customer-visible traceback, so it should not be part of the serialized form of the exception at all.
Packages affected
Both — core and langchain version together per the repo's lockstep rule.
1.18.0→1.18.51.18.4→1.18.5, with itsuipath-llm-clientfloor raised to>=1.18.5Tests
Three tests added in
tests/core/features/test_exceptions.py:test_str_omits_the_response_body(parametrized over a JSON and a text body) — asserts the body content is absent and pins the exact new formattest_str_omission_does_not_drop_the_body_attribute— guards that.bodystill carries the payload for callers that classify on itRed-green verified: both
test_str_omits_the_response_bodycases fail against the old__str__and pass with the fix.Verification
ruff check— all checks passedruff format .— 165 files unchangedpyright— 0 errors, 0 warningspytest tests— 650 passed, 35 skipped, 9 xfailed (up from 647 onmain)The 2507 fixture errors in the local run are pre-existing and identical on a clean tree —
tests/conftest.py:85buildsLLMGatewaySettings(), which needsLLMGW_URL/LLMGW_SEMANTIC_*env vars that aren't set locally. CI supplies them.🤖 Generated with Claude Code
https://claude.ai/code/session_01BnGx1AgzrA4Qq1bRrbvjyd