Skip to content

fix(pii): load default detectors at startup + add LOCALAI_PII_DEFAULT_DETECTORS#10474

Merged
mudler merged 2 commits into
mudler:masterfrom
richiejp:fix/mitm-pii-settings
Jun 24, 2026
Merged

fix(pii): load default detectors at startup + add LOCALAI_PII_DEFAULT_DETECTORS#10474
mudler merged 2 commits into
mudler:masterfrom
richiejp:fix/mitm-pii-settings

Conversation

@richiejp

Copy link
Copy Markdown
Collaborator

Description

Make the global PII detectors actually take effect and add a env var to set
them in addition to the JSON config.

Notes for Reviewers

pii_default_detectors was applied to the live config only by a live
POST /api/settings (ApplyRuntimeSettings) — neither the startup loader nor
the config file watcher read it back. So after a restart the persisted
default detectors were dropped, and the cloud-proxy MITM listener (which
resolves each intercept host's detectors once at start via ResolvePIIPolicy)
came up with an empty set and forwarded intercepted traffic unredacted, even
though the MITM model had pii.enabled:true and the defaults were on disk.
Request-side default redaction broke the same way.

  • startup.go: loadRuntimeSettingsFromFile now applies pii_default_detectors,
    before startMITMIfConfigured, with env > file precedence.
  • config_file_watcher.go: apply pii_default_detectors on live file edits,
    matching the existing env-guard pattern used for the other fields.
  • settings endpoint: rebuild the MITM listener when pii_default_detectors
    changes (its per-host detector map is frozen at listener start), not only
    on a mitm_listen change — so toggling a default detector takes effect on
    cloud-proxy traffic immediately.
  • new LOCALAI_PII_DEFAULT_DETECTORS env var / CLI flag (WithPIIDefaultDetectors)
    so the default detector set can be pinned at boot for immutable deployments.

Assisted-by: Claude:claude-opus-4-8 Claude-Code
Signed-off-by: Richard Palethorpe io@richiejp.com

Signed commits

  • Yes, I signed my commits.

richiejp and others added 2 commits June 23, 2026 20:42
…_DETECTORS

pii_default_detectors was applied to the live config only by a live
POST /api/settings (ApplyRuntimeSettings) — neither the startup loader nor
the config file watcher read it back. So after a restart the persisted
default detectors were dropped, and the cloud-proxy MITM listener (which
resolves each intercept host's detectors once at start via ResolvePIIPolicy)
came up with an empty set and forwarded intercepted traffic unredacted, even
though the MITM model had pii.enabled:true and the defaults were on disk.
Request-side default redaction broke the same way.

- startup.go: loadRuntimeSettingsFromFile now applies pii_default_detectors,
  before startMITMIfConfigured, with env > file precedence.
- config_file_watcher.go: apply pii_default_detectors on live file edits,
  matching the existing env-guard pattern used for the other fields.
- settings endpoint: rebuild the MITM listener when pii_default_detectors
  changes (its per-host detector map is frozen at listener start), not only
  on a mitm_listen change — so toggling a default detector takes effect on
  cloud-proxy traffic immediately.
- new LOCALAI_PII_DEFAULT_DETECTORS env var / CLI flag (WithPIIDefaultDetectors)
  so the default detector set can be pinned at boot for immutable deployments.

Assisted-by: Claude:claude-opus-4-8 Claude-Code
Signed-off-by: Richard Palethorpe <io@richiejp.com>
@mudler mudler merged commit e199457 into mudler:master Jun 24, 2026
58 checks passed
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.

2 participants