#11093·promptfoo

Single-string `tests:` ignores globs (documented `tests: file://tests/*` silently loads 0 tests)

Author: hardness1020Created Sep 26, 2026Updated Sep 26, 2026

Describe the bug

When tests is a single string instead of an array, promptfoo only expands globs for strings ending in yaml/yml. Every other string is read as one literal file path. Because of that:

  • The form documented in site/docs/configuration/guide.md (tests: file://tests/*) loads 0 tests without a warning. The eval then runs one row with empty vars (the documented behavior when tests is omitted), reports it as passed, and exits 0. A CI gate built on this config passes without testing anything.
  • tests: file://tests/*.csv fails with ENOENT on the literal *.csv path.

Wrapping the same string in an array (tests: ['file://tests/*']) works correctly.

To Reproduce

Directory layout:

promptfooconfig.yaml
tests/a.csv          # q\nfrom-a-csv
tests/b.csv          # q\nfrom-b-csv
tests/a.json         # [{"vars": {"q": "from-a-json"}}]
tests/cases.yaml     # - vars: {q: from-yaml}

Config:

yaml
prompts: ['{{q}}']
providers: [echo]
tests: file://tests/*

Run npx promptfoo eval -c promptfooconfig.yaml --no-cache -o out.json, then change only the tests line:

tests: value Result
file://tests/* "Running 1 test cases", 1 passed, exit 0, one row with no vars, no warning
['file://tests/*'] 4 tests loaded, all pass
file://tests/*.csv ENOENT: no such file or directory, open '.../tests/*.csv', exit 1
['file://tests/*.csv'] 2 tests loaded, all pass

The CLI flag -t 'tests/*.csv' goes through the same string branch and fails the same way. So does the Node API, evaluate({ tests: 'file://tests/*', ... }), which reaches the same readTests call through createRuntimeTestSuite in src/evaluate.ts. -t is documented only as "Path to CSV with test cases", so glob support there would come from the shared code path, not from a documented contract.

Expected behavior

A single-string glob should expand the same way as the one-element array form. tests: file://tests/* should load the same 4 tests as tests: ['file://tests/*'], and tests: file://tests/*.csv the same 2 tests as tests: ['file://tests/*.csv'].

Two other code paths already work this way:

  • Scenarios. prepareCombinedConfig in src/util/config/load.ts wraps a scenario's tests with [scenario.tests].flat(). So scenarios: [{ config: [{}], tests: 'file://tests/*' }] loads the 4 tests today.
  • Watch mode. resolveTestsWatchPaths in src/util/testCaseReader.ts wraps a string in an array and expands its glob. With --watch, the watcher tracks the 4 matched files while the loader reads none of them.

On main, site/docs/configuration/test-cases.md states the contract: "An unmatched test-source glob warns and adds no rows; a missing literal test file is an error." The string form breaks this for globs. tests/* matches 4 files but adds no rows and logs no warning. tests/*.csv matches 2 files but fails as a missing literal file.

Root cause

readTestsWithEnv in src/util/testCaseReader.ts (string branch):

typescript
if (typeof tests === 'string') {
  ...
  if (tests.endsWith('yaml') || tests.endsWith('yml')) {
    return loadTestsFromGlobWithEnv(tests, basePath, env, loadProviders);
  }
  return loadStandalone(tests); // -> readStandaloneTestsFile
}

readStandaloneTestsFile resolves one literal path and never expands globs. For a local path with an unknown or empty extension, readLocalStandaloneTestsFile returns [] without a warning. tests/* has no extension, so it silently loads nothing. tests/*.csv goes to the CSV reader, which tries to open the literal path.

The array branch already routes entries by type. Remote sources, JS/Python, XLSX and :fn references go to loadStandalone. Everything else goes to loadTestsFromGlobWithEnv.

Proposed fix

Send glob strings through the existing array routing, except those that end in yaml/yml or name an existing file. YAML strings and literal paths stay on their current loaders:

typescript
if (typeof tests === 'string') {
  tests = renderEnvOnlyInObject(tests);
  if (tests.startsWith('az://')) {
    return loadStandalone(tests);
  }
  if (tests.endsWith('yaml') || tests.endsWith('yml')) {
    return loadTestsFromGlobWithEnv(tests, basePath, env, loadProviders);
  }
  // Other globs: reuse the array routing so matches expand like `tests: [glob]`
  const withoutScheme = tests.replace(/^file:\/\//, '');
  if (hasGlobMagic(withoutScheme) && !fs.existsSync(path.resolve(basePath, withoutScheme))) {
    return readTestsWithEnv([tests], basePath, env, loadProviders);
  }
  return loadStandalone(tests);
}

Why not route every string through the array branch? A literal .json/.jsonl string would then move from the standalone loader to the glob loader, and those behave differently:

  • The glob loader eagerly runs maybeLoadConfigFromExternalFile on every field.
  • It runs $RefParser.dereference.
  • It parses JSON with strict JSON.parse instead of the YAML-tolerant parser.
  • It doesn't add the Row #N default descriptions.

That would break string-form JSON configs that work today. Examples:

  • a row with "provider": "file://prov.js";
  • an is-json schema with an internal $ref;
  • a .json file that is valid YAML but not strict JSON;
  • the existing test test/util/config/envReload.test.ts › "resolves a standalone typed grader relative to the suite directory".

The existsSync check keeps an existing file whose name contains glob characters (e.g. cases[draft].json) on its current loader. Without it, such a file would hit the loader differences above. loadTestsFromGlobWithEnv does the same existsSync check before globbing.

The new check goes after the yaml/yml branch, so YAML globs keep their current path. If it went first, YAML globs would move to the array routing. Its :fn check treats any colon after the drive letter as a function suffix. A YAML glob under a directory like run:1/ would then load 0 tests instead of its matches.

Remote URLs that contain ? (Google Sheets, SharePoint, Hugging Face) count as glob magic. The array routing still sends them to loadStandalone before any glob handling, the same as today.

I tried this change locally on main @ d833727ce:

  • file://tests/* loads 4 tests.
  • file://tests/*.csv loads 2 tests.
  • Literal .json, .jsonl and directory strings behave as before, including existing files with glob characters in their names.
  • file://run:1/*.yaml still loads its match.
  • Existing tests are unchanged. npx vitest run --maxWorkers=4 test/util test/commands test/node test/evaluator test/index.test.ts test/evaluate.jsonl.test.ts test/per-test-config.test.ts test/googleSheets.test.ts gives 169 files, 4411 passed, 1 skipped. That's the same count as on main, and the new regression tests below aren't included. I used --maxWorkers=4 because my machine was heavily loaded.

Plus regression tests in test/util/testCaseReader.test.ts for the string form:

  • a * glob across csv/json/yaml;
  • a *.csv glob;
  • a glob with no matches.

Visible side effects:

  • A string glob that matches nothing (e.g. tests: file://nomatch/*.csv, or -t 'nomatch/*.csv') no longer fails with ENOENT and exit 1.
    • It now logs No test files found for path: ... as a warning, runs one row with empty vars, reports it as passed, and exits 0.

    • This matches the documented contract quoted above ("An unmatched test-source glob warns and adds no rows"). It's also what the array form (['file://nomatch/*.csv']) and the string YAML glob (file://nomatch/*.yaml) already do.

    • So a mistyped *.csv or *.json glob that fails CI today would pass after the fix, with only a warning.

    • Any other string with glob syntax that doesn't match as written is treated the same way: a warning and no rows, instead of today's ENOENT. Two examples:

      • a missing missing[draft].json;
      • lit[1]/*.csv where the directory is literally named lit[1], since [1] is read as a character class.

      The array form already does this.

  • A string glob that matches files the loaders don't treat as data now behaves like the array form:
    • A subdirectory or an unknown extension (e.g. tests/* with tests/sub/ or tests/README.md) fails with Unsupported file type for test file: ... instead of silently loading nothing.
    • A matched JS/TS (.js, .cjs, .mjs, .ts, .cts, .mts) or .py file is imported or run as a test generator. So a helper script kept next to the data, such as a Python get_assert file, now executes and usually fails with an error like module 'check' has no attribute 'generate_tests'.
    • A matched .json/.jsonl file goes through the glob loader, with the differences listed under "Why not route every string". For example, a matched JSON row with "provider": "file://prov.js", or a YAML-style .json file, now fails.

System information:

  • Promptfoo version: 0.123.1 (npm release) and main @ d833727ce. The table rows reproduce on both. On main, the *.csv error is prefixed with Failed to load tests from ...:. On 0.123.1 it prints the bare Error: ENOENT ... with a stack trace.
  • Node: 24.21.0
  • OS: macOS

Additional context

  • Related gap: directory form. Directory references are documented in two places:

    • site/docs/configuration/guide.md: "takes a list of paths to files or directories";
    • site/docs/configuration/modular-configs.md.

    Their current behavior:

    • As a string (tests: file://tests/), a directory also silently loads 0 tests.
    • As an array (tests: ['file://tests/accuracy/', ...]), it fails with "Unsupported file type".

    The fix above doesn't change either behavior. That could be a follow-up.

  • Related gap: JS/Python/XLSX globs. Globs of .js, .py or .xlsx files aren't expanded in either form. The array routing sends them to loadStandalone as literal paths. This is out of scope here.

  • Related gap: JSON/JSONL whole-field refs. A string-form JSON/JSONL test file doesn't resolve refs that must be in place at load time. For example, a row with "assert": "file://j/asserts.yaml" fails with AssertValidationError: tests[0].assert must be an array, while ['file://j/t.json'] loads it. Refs that are resolved later still work in the string form, such as an assertion value: file://expected.txt. The difference comes from the two loaders:

    • the standalone JSON/JSONL readers apply neither maybeLoadConfigFromExternalFile nor $ref dereferencing;
    • the standalone YAML reader applies maybeLoadConfigFromExternalFile;
    • the glob loader applies both.

    The fix above doesn't change this, and aligning the loaders runs into the differences listed under "Why not route every string".

  • Open PRs. #8866 and #9419 touch JSON/JSONL file:// resolution in readStandaloneTestsFile. Neither changes how string globs are routed.