Skip to content

fix: show Unknown instead of masked value when entity label missing#345

Merged
hanneshapke merged 1 commit intomainfrom
fix/pii-type-label-fallback
Apr 24, 2026
Merged

fix: show Unknown instead of masked value when entity label missing#345
hanneshapke merged 1 commit intomainfrom
fix/pii-type-label-fallback

Conversation

@hanneshapke
Copy link
Copy Markdown
Collaborator

Summary

  • The PII modal's Type column was showing the masked replacement itself (e.g. `25627`) instead of the entity label (e.g. `Zip`) when the backend response didn't carry a matching label for a given masked value.
  • Root cause: `formatEntityType` fell back to stripping `<>` and `_N` from the masked value. That was designed for legacy bracket tokens like `<PERSON_1>`, but for modern realistic-fake replacements (e.g. `25627`) the regex is a no-op and the masked value ends up rendered verbatim as the type.
  • Fix: only use the bracket-token fallback when the masked value actually matches `` / `<LABEL_N>`. Otherwise return `Unknown`, so missing labels are at least not misleading.

Before / After

Before (zipcode row):

Type Found Replaced with
25627 97204 25627

After (when label is present):

Type Found Replaced with
Zip 97204 25627

After (when label is missing for any reason):

Type Found Replaced with
Unknown 97204 25627

Test plan

  • Load the unpacked extension in Chrome
  • Submit a prompt containing a zipcode in ChatGPT and confirm the Type column shows `Zip`, not the masked value
  • Submit a prompt with multiple entity types (name, email, zipcode) and confirm each Type is formatted correctly
  • Point the extension at a server that does not return `detected_entities` and confirm Type shows `Unknown` (not the masked value)

🤖 Generated with Claude Code

The PII modal's Type column rendered the masked replacement itself
(e.g. "25627") when the backend response lacked a matching label —
the legacy bracket-token fallback in formatEntityType returned the
masked value unchanged for modern realistic-fake replacements.

Guard the fallback so it only fires for `<LABEL_N>` shaped tokens.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hanneshapke hanneshapke merged commit db65319 into main Apr 24, 2026
6 checks passed
@hanneshapke hanneshapke deleted the fix/pii-type-label-fallback branch April 24, 2026 18:28
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