PII Remover: Fix validator on_fail error
维护者通常 3 天内回复
@AkhileshNegi 已经在做这个了。
开始于 2026年10月15日。
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- Python
- 星标
- 5
- 派生
- 4
- 平均合并
- 6 天 1 小时
- 30 天内合并 PR
- 10
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ProjectTech4DevAI/kaapi-guardrails 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
ProjectTech4DevAI/kaapi-guardrails#94 ·
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
ProjectTech4DevAI/kaapi-guardrails#23 ·
维护者通常 3 天内回复
-
Callback Enhancement: Include intermediate responses可能重新可做 @Prajna1999 于 42 天前认领,目前没有进行中的 PR。 未关闭
ProjectTech4DevAI/kaapi-guardrails#158 · 已指派 1 人 ·
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
ProjectTech4DevAI/kaapi-guardrails#137 ·
维护者通常 3 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
ProjectTech4DevAI/kaapi-guardrails#134 ·
维护者通常 3 天内回复
查看 ProjectTech4DevAI/kaapi-guardrails 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
pgvector/pgvector-python#169 ·
-
ChaosEngine: backup-remote doctor row passes while consumer mode hides bot memory from git可能已有人在做 @MohabMohie 今天认领。 未关闭agentic
难度 2/5 1-3 小时 新手友好度 76/100
ShaftHQ/SHAFT_ENGINE#7263 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 87/100
huggingface/smolagents#3045 ·
维护者通常 1 天内回复