Skip to content

Trying to redact PII on error messages if not successful response - #1399

Merged
eschultink merged 1 commit into
rc-v0.6.10from
api_error_logging
Aug 26, 2026
Merged

Trying to redact PII on error messages if not successful response#1399
eschultink merged 1 commit into
rc-v0.6.10from
api_error_logging

Conversation

@aperez-worklytics

Copy link
Copy Markdown
Contributor

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

paste links to issues/tasks in project management

Features

copilot errors

Logistics

paste links to issues/tasks in project management

Change implications

  • dependencies added/changed? no
  • something important to note in future release notes?
    • NOTE in CHANGELOG.md anything that will show up in terraform plan/apply that isn't
      obviously a no-op?
    • breaking changes? if in module/example that is NOT marked alpha, requires major version
      change

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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.

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 ApiDataRequestHandler to 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i don't feel strongly about this in logs, but OK.

@eschultink
eschultink merged commit c81216b into rc-v0.6.10 Aug 26, 2026
120 checks passed
@eschultink
eschultink deleted the api_error_logging branch August 26, 2026 15:29
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.

3 participants