Repository navigation
Fixes #36328: skip custom recognizers Presidio cannot compile - #36329
Conversation
…mpile A pattern recognizer with an invalid regex or no patterns raised during analysis and failed the whole column, dropping every other tag on it. Compile the patterns when the recognizer is built and skip it with an error log instead. Escape context words so they match literally, and keep a minScore of 0.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
@TeddyCr @Khairajani could one of you add the |
regex raises RecursionError, not regex.error, for a pattern such as
'(' * 350 + 'a' + ')' * 350, so the pre-compilation check let it escape
and fail the column, even for a recognizer in another language.
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Head branch was pushed to by a user without write access
5ba4b9a to
b4cfd83
Compare
Code Review ✅ Approved 🟡 Medium riskChanging PII recognizer compilation, literal context matching, and zero-score handling could alter detected tags and produce false positives or negatives. Skips custom pattern recognizers that Presidio cannot compile instead of failing the whole column, escapes context words so regex characters match literally, and fixes VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |



Describe your changes:
Fixes #36328
A pattern recognizer with an invalid regex or with no patterns raised during analysis (Presidio compiles patterns on first use, and rejects an empty pattern list), so the whole column failed and lost every other tag scored for it. The same happened to a context recognizer whose context word contains regex characters, because the words went into the regex unescaped.
_create_pattern_recognizercompiles the patterns withregex(what Presidio uses) and the recognizer's flags while building it. If that or Presidio's constructor fails, it logs an error and returnsNone, so only that recognizer is skipped. Built-in recognizers are untouched.c++andid (internal)match literally anda.k.ano longer matchesaXkXa.minScore: 0is no longer treated as unset (it scored 0.6 even withmaxScore: 0.4).Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
patterns: []) no longer stops another tag on the same column from being applied.minScore: 0scores the midpoint.Unit tests
tests/unit/pii/algorithms/test_presidio_recognizer_factory.py,tests/unit/metadata/pii/test_tag_scoring.pytests/unit/piiandtests/unit/metadata/piipass.presidio_recognizer_factory.py(the uncovered lines are existing branches this PR does not touch)Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
ScoreTagsForColumnServiceforPII.Sensitiveplus a custom tag whose recognizer is broken (invalid regex, emptypatterns, or a context wordid (internal).PII.Sensitiveis returned, and the broken recognizer is logged and skipped.UI screen recording:
Not applicable — ingestion-only bug fix.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under
docs/decisions/(see itsREADME.md). This description is gone fromgit logafter the squash-merge.I have added a test that covers the exact scenario we are fixing.
AI assistance (Claude Code) was used for this change.


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
The PR skips custom pattern recognizers that Presidio cannot compile, without dropping other tags.
Reviews (1) · Last reviewed commit: "Fixes #36328: skip custom recognizers Pr..." · Reviewed by Greptile