fix(csv): reject __expected0 instead of silently dropping its config#9815
Merged
ianw-oai merged 1 commit intoJun 21, 2026
promptfoo:mainpromptfoo/promptfoo:mainfrom
he-yufeng:fix/csv-expected-index-zerohe-yufeng/promptfoo:fix/csv-expected-index-zeroCopy head branch name to clipboard
Merged
fix(csv): reject __expected0 instead of silently dropping its config#9815ianw-oai merged 1 commit intopromptfoo:mainpromptfoo/promptfoo:mainfrom he-yufeng:fix/csv-expected-index-zerohe-yufeng/promptfoo:fix/csv-expected-index-zeroCopy head branch name to clipboard
ianw-oai merged 1 commit into
promptfoo:mainpromptfoo/promptfoo:mainfrom
he-yufeng:fix/csv-expected-index-zerohe-yufeng/promptfoo:fix/csv-expected-index-zeroCopy head branch name to clipboard
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9815 +/- ##
=======================================
Coverage 79.26% 79.26%
=======================================
Files 917 917
Lines 73607 73609 +2
Branches 23661 23662 +1
=======================================
+ Hits 58342 58344 +2
Misses 15265 15265
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
he-yufeng
force-pushed
the
fix/csv-expected-index-zero
branch
2 times, most recently
from
June 20, 2026 13:06
9ecc4f1 to
a9d227f
Compare
he-yufeng
force-pushed
the
fix/csv-expected-index-zero
branch
from
June 21, 2026 17:36
a9d227f to
72fbee8
Compare
ianw-oai
approved these changes
Jun 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A
__config:__expected0:thresholdcolumn is silently dropped instead of being rejected.__expected<N>indices are 1-based (__expected1→ assertion 0). The parser runsNumber.parseInt(n, 10) - 1, so__expected0becomes-1. That isn'tundefined, so it slips past the "must be a positive integer" guard, and the config is written toassertionConfigs[-1]— a property the apply loop (for i = 0..asserts.length) never reads. The threshold just vanishes with no error.This is inconsistent with
__expectedX(non-numeric), which already throwsInvalid expected key ... Must be __expected or __expected<N> where N is a positive integer.This change makes__expected0take that same path by only assigningtargetIndexwhen the index is>= 1.Why
The error message already promises that
Nmust be a positive integer, but0was accepted and then silently no-op'd. A user who indexes from 0 loses their threshold config without any signal. Erroring matches the documented contract and the existing__expectedXbehavior.Testing
Added a
test/csv.test.tscase asserting__config:__expected0:thresholdthrows the same "positive integer" error as__expectedX. It fails onmain(expected [Function] to throw an error, since the config is silently dropped) and passes with this change.npx vitest run test/csv.test.tsis green;tsc --noEmitand prettier/biome are clean (the pre-existing complexity warning ontestCaseFromCsvRowis unrelated).