Skip to content

bug(platform): Guardrails drops saved custom PII patterns on load and deletes them on the next PII save #4833

Closed

Description

@yannickmonney

Problem

Settings › Governance › Guardrails drops every saved custom PII pattern when it loads, then deletes them on the next PII save. Paths at main acd5dbd10.

  1. Saved shape. Custom patterns are stored in the shape the shared schema enforces, { name, regex, replacement }: piiCustomPatternSchema in packages/shared/src/schemas/pii.ts:49-79 is .strict(). The panel writes that shape (app/features/settings/governance/components/pii/pii-config-panel.tsx:348-353), and its type is PiiCustomPattern (:69).
  2. Load filter. app/features/settings/governance/components/pii-config.tsx:88-90 keeps only entries passing isCustomPattern. That guard (:99-110) requires a string field named pattern, which a stored entry never has. So every saved custom pattern is filtered out, and the panel shows none.
  3. Next save. Any later PII save (the enable switch, the mode, a built-in pattern checkbox) sends customPatterns: nextValue.customPatterns.filter(…) (:175-178), which is now []. The admin's custom rules are deleted without a word, and the PII scrubber stops applying them.

Why nothing catches it: every case in pii-config.test.tsx uses customPatterns: [] (:42, :63, :75, :91), so no test loads a saved custom pattern. The guard's pattern check predates #4292, the file's latest change (it is already present at 68af0bc212^).

Who is affected: any organization that added custom patterns (for example an internal ID format) loses them the first time anyone saves a PII setting. Until then the admin is told none exist, and may add them again, only for them to vanish again.

Expected

  • isCustomPattern checks regex and replacement, matching PiiCustomPattern, or parses with piiCustomPatternSchema.
  • Never write a smaller customPatterns than the server holds because of a client-side filter. If an entry can't be read, show it as unreadable instead of dropping it.
  • Regression: a pii-config test that loads a policy with one saved custom pattern. It shows that pattern, and a mode change saves it unchanged. On acd5dbd10 the pattern is missing and the save sends [].
  • Recovery note: organizations that saved PII settings since custom patterns were added may already have lost them. Check the audit log's policy history for earlier customPatterns.

Severity and owner

  • Severity: high. It is silent loss of a privacy control's configuration, triggered by an ordinary save.
  • Owner: platform (governance, guardrails).
  • Found by: Review A (TALE-358), 2026-10-12 08:15 Zurich occurrence, oldest-due governance.guardrails slice. This is static reading at acd5dbd10, verified against the shared schema and the backend (lib/pii/resolve-config.ts passes customPatterns through unchanged). I didn't run it, because Review A's stack is BLOCKED.

Activity

  1. yannickmonney commented on Oct 12, 2026

    @yannickmonney
    ContributorAuthor

    Review A recheck (TALE-358, 2026-10-12 20:15 Zurich occurrence): fixed on main c94f1fd84. I read the merged source statically and checked the CI run on that exact commit; no live stack was used. Paths are under services/platform/app/features/settings/governance/components/.

    • Load: saved rules are parsed with the strict shared schema (pii-config.tsx:92), so { name, regex, replacement } entries survive.
    • Save: a save sends the array unchanged (:174).
    • Unreadable rules: an array that fails the schema switches the editor to the existing Retry surface and fences writes (isPiiPolicyReadable, :102-105; policy-read-boundary.tsx:105-106). Enabling a custom-only policy keeps its mode (:204).
    • Regression proof: pii-config.browser.test.tsx ran uncached and passed in main's Checks run 38287683781 (job "Browser", 114939862010; @tale/platform#test:browser turbo MISS, 67 files).
    • Gap in the v0.5.87 notes (.github/release-notes/v0.5.87.md:12): they say custom rules now survive, but not that rules may already have been deleted on earlier versions. Please add this issue's recovery note: an organization that saved any PII setting since adding custom rules should check the audit log's policy history for earlier customPatterns and re-add them. Otherwise admins have no reason to look.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions