Repository navigation
Commit acedfa6
authored
fix(eval): raise the Invalid filter error for filters without an equals sign (#826)
## Summary
`parse_filters` looks for the `=` separator with `str.index`, which
raises `ValueError: substring not found` when the separator is missing.
The `-1` check and the `Invalid filter` message that follow it never
run. This change switches to `str.find` so a filter without `=` raises
`ValueError: Invalid filter <filter>`, matching the JavaScript SDK.
## Changes
- Use `str.find("=")` in `parse_filters` so the existing `Invalid
filter` error is reachable.
- Add tests for the error message and for splitting on the first `=`
only.
## Testing
```
cd py
python -m pytest src/braintrust/test_framework.py -k "parse_filters or evaluate_filter"
```
Before the change: 1 failed, 9 passed. After the change: 10 passed.1 parent ed5dba4 commit acedfa6
2 files changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
1160 | | - | |
| 1160 | + | |
1161 | 1161 | | |
1162 | 1162 | | |
1163 | 1163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1462 | 1462 | | |
1463 | 1463 | | |
1464 | 1464 | | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
1465 | 1474 | | |
1466 | 1475 | | |
1467 | 1476 | | |
| |||
0 commit comments