PII Remover: Fix validator on_fail error
Maintainer thường phản hồi trong vòng 3 ngày
@AkhileshNegi đang làm issue này rồi.
Từ ngày 15/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Is your feature request related to a problem?
Running any pii_remover validator fails at run time with an invalid on_fail value. This causes job failures and prevents users from processing configurations correctly.
Describe the solution you'd like
- Remove
use_enum_valuesfromPIIRemoverSafetyValidatorConfig. - Convert
entity_typesto.valuestrings in thebuild()method before passing to Presidio. - Maintain enum types for strict validation in the model.
- Add a regression test to validate all three
on_failvalues.
Original issue
Bug
Running any pii_remover validator (saved config or inline) fails at run time:
Invalid on_fail value: fix. Expected one of: exception, fix, rephrase.
Reproduced on staging via kaapi-backend POST /guardrails with a PII config (on_fail_action: fix), job status FAILED, no output.
Root cause
PR #165 added model_config = ConfigDict(use_enum_values=True) to PIIRemoverSafetyValidatorConfig so Presidio receives plain-string entity types. use_enum_values is model-wide, so it also coerces the inherited on_fail: GuardrailOnFail and stage: Stage fields to plain strings.
BaseValidatorConfig.resolve_on_fail()comparesself.on_fail == GuardrailOnFail.Fix.GuardrailOnFailis a plainEnum(nostrmixin), so"fix" != GuardrailOnFail.Fixand the method falls through toraise ValueError(...).routes/guardrails.pycallsconfig.stage.valuewhen writing validator logs; withstagecoerced to"input"this raisesAttributeError: 'str' object has no attribute 'value'.
Unit tests missed it because they relied on the default on_fail; pydantic does not validate defaults, so the enum stayed an enum.
PIIRemoverSafetyValidatorConfig(type="pii_remover", on_fail="fix").resolve_on_fail()
# ValueError: Invalid on_fail value: fix. ...
PIIRemoverSafetyValidatorConfig(type="pii_remover", stage="input").stage.value
# AttributeError: 'str' object has no attribute 'value'
Fix
Drop use_enum_values and convert entity_types to .value strings inside build(), right before handing them to Presidio. Enums stay on the model (strict validation unchanged), Presidio still gets plain strings. Add a regression test that passes on_fail explicitly for all three values.
- Ngôn ngữ chính
- Python
- Star
- 5
- Fork
- 4
- Merge trung bình
- 6 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ProjectTech4DevAI/kaapi-guardrails
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ProjectTech4DevAI/kaapi-guardrails#94 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
ProjectTech4DevAI/kaapi-guardrails#23 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Callback Enhancement: Include intermediate responsesCó thể làm lại được @Prajna1999 đã nhận 41 ngày trước và không có pull request nào đang mở. Đang mở
ProjectTech4DevAI/kaapi-guardrails#158 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Kaapi Console: Display config idĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
ProjectTech4DevAI/kaapi-guardrails#137 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
ProjectTech4DevAI/kaapi-guardrails#134 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của ProjectTech4DevAI/kaapi-guardrails
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue module-baseline needs triage ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
darnitdevorg/darnit#650 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
nyjc-computing/campus#938 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nf-osi/nf-metadata-dictionary#1027 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
qatrackplus/qatrackplus#913 ·
Maintainer thường phản hồi trong vòng 3 ngày