Commit a756e3f
committed
fix(policy): contains operator case-insensitive on list-membership branch
Pre-fix:
case "contains":
if isinstance(val, str) and isinstance(pv, str):
return pv.lower() in val.lower() # CI
return isinstance(val, (list, tuple, set)) and pv in val # case-SENSITIVE
The string-in-string branch was already case-insensitive (matching the
``_ci``-equivalent treatment that ``eq`` / ``in`` / ``not_in`` apply),
but the list-membership branch fell through to Python's default ``in``
operator. A rule listing ``["light.kitchen"]`` would not fire on an
LLM passing ``["Light.Kitchen"]`` — silent gate failure.
Bring it in line with the other string-op branches via per-element
``_ci``, which passes non-string entries through unchanged so
mixed-type collections still get natural equality semantics.
Caught by Gemini Code Assist on homeassistant-ai#1431; addressing inline rather than
opening a follow-up because the policy module is now in master
(homeassistant-ai#1421) and any reviewer running the suite would see the
case-sensitivity asymmetry in the existing TestCaseInsensitive class.1 parent 3e96694 commit a756e3f
2 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
198 | 217 | | |
199 | 218 | | |
200 | 219 | | |
| |||
0 commit comments