Skip to content

fix(eval): raise the Invalid filter error for filters without an equals sign - #826

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
braintrustdata:mainfrom
RaphaelFakhri:fix/parse-filters-invalid-filter-error
Sep 29, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 1 commit into
braintrustdata:mainfrom
RaphaelFakhri:fix/parse-filters-invalid-filter-error

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

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.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit acedfa6 into braintrustdata:main Sep 29, 2026
83 checks passed
@AbhiPrasad

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants