Trying to redact PII on error messages if not successful response - #1399
Conversation
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
Pull request overview
This PR reduces potential PII exposure by redacting common PII-like patterns (email addresses and UUIDs/GUIDs) from source API error response bodies before they are logged and returned to the caller. This fits into the proxy’s broader goal of preventing sensitive data from leaking via logs or unsanitized payloads, particularly for unstructured/unknown-schema error bodies where schema-based sanitization can’t be applied.
Changes:
- Added
LogSanitizationUtils.redactPotentialPii(...)to scrub emails and UUIDs from free-text content. - Updated
ApiDataRequestHandlerto apply best-effort redaction for non-success source API responses before logging and returning the error body. - Added unit tests covering null input, a UUID-bearing Microsoft Graph-style error, email redaction, and a no-match pass-through case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| java/core/src/main/java/co/worklytics/psoxy/utils/LogSanitizationUtils.java | Introduces a small utility for best-effort redaction of emails and UUIDs in unstructured text (e.g., error bodies). |
| java/core/src/main/java/co/worklytics/psoxy/gateway/impl/ApiDataRequestHandler.java | Applies PII redaction to source API error bodies before logging and returning them when the upstream response is not successful. |
| java/core/src/test/java/co/worklytics/psoxy/utils/LogSanitizationUtilsTest.java | Adds unit tests to verify redaction behavior and that non-matching content remains unchanged. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // APIs, eg MSFT Graph) on a best-effort basis before logging or returning it | ||
| String redactedError = | ||
| LogSanitizationUtils.redactPotentialPii(original.getContentAsString()); | ||
| log.log(Level.WARNING, "Source API Error " + redactedError); |
There was a problem hiding this comment.
i don't feel strongly about this in logs, but OK.
In case the response is not successful, trying to redact emails or UUIDs from the message to avoid putting in logs/response payload potential PII data
Fixes
Features
copilot errors
Logistics
Change implications
CHANGELOG.mdanything that will show up interraform plan/applythat isn'tobviously a no-op?
alpha, requires major versionchange