Repository: promptfoo/promptfoo
Issue: Misleading error: [FAIL] Error: Invariant failed: context-faithfulness assertion type must have a question var 
Root cause: Validation Gap

**Describe the bug**
When evaluating a RAG I am getting an error that my tests for context-faithfullness, context-relevance must a question va:

```
[FAIL] Error: Invariant failed: context-faithfulness assertion type must have a question var 
```

Full log:
```
Error: Invariant failed: context-relevance assertion type must have a question var

Error: Invariant failed: context-relevance assertion type must have a question var
    at invariant (/usr/local/lib/node_modules/promptfoo/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:14:11)
    at runAssertion (/usr/local/lib/node_modules/promptfoo/dist/src/assertions.js:894:38)
    at /usr/local/lib/node_modules/promptfoo/dist/src/assertions.js:1138:30
    at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:151:38
    at replenish (/usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:447:21)
    at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:452:13
    at Object.eachOfLimit (/usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:478:36)
    at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:220:25
    at new Promise (<anonymous>)
    at Object.awaitable (/usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:215:20)
```
I have my question var, but it's not being detected properly.

**To Reproduce**

Use the following Promptfoo configuraiton:

```yaml
description: "RAG - Model generation evals"

prompts:
  - |
    Based on the following docs as context:
    <context>
    {{context}}
    </context>

    Answer the following question:
    <question>
    {{question}}
    </question>

providers:
  - id: ollama:chat:gemma2:9b:latest
    label: gemma2_9b
    config:
      temperature: 0
      
defaultTest:
  options:
    provider:
      text:
        id: ollama:chat:gemma2:9b:latest
      embedding:
        id: ollama:embeddings:nomic-embed-text:latest
  assert:
    - type: context-relevance
      threshold: 0.9
    - type: context-faithfulness
      threshold: 0.9
    - type: answer-relevance
      threshold: 0.9

tests:
  - vars:
      question: "What is the capital of Balearic Islands?"
      context: file://q1.txt
```

Note that the test variable is called question specifically.

**Expected behavior**
It should detect the question used in the test.

**System information (please complete the following information):**

- Promptfoo version: 0.78.3

**Additional context**

Replacing `question` for `query` in the previous config file fixes the problem, so it might be a mismatch between error message and the actual check being performed. (However, the checks for the asserts return No Output, for 2 out of 3 models, but that might be another issue)


Hi @elsatch, thank you for bringing this issue to our attention. I just merged a fix for this in [PR #1485](https://github.com/promptfoo/promptfoo/pull/1485), and I'll cut a release tomorrow. We appreciate your detailed report and your help in improving promptfoo. If you encounter any further issues or have additional feedback, please don't hesitate to reach out. Thank you again!