Repository: promptfoo/promptfoo
Issue: Minified React error #31 when outputting a nested object in transformVars
Root cause: Interface Contract Mismatch

**Describe the bug**
If transformVars outputs a nested object, web UI shows:
```
Unexpected Application Error!
Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7Bfoo%7D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7Bfoo%7D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Ex (http://localhost:15500/assets/index-CrA60y6F.js:38:6337)
    at b (http://localhost:15500/assets/index-CrA60y6F.js:38:11395)
    at ls (http://localhost:15500/assets/index-CrA60y6F.js:40:1479)
    at ZY (http://localhost:15500/assets/index-CrA60y6F.js:40:45814)
    at YY (http://localhost:15500/assets/index-CrA60y6F.js:40:39822)
    at _Ae (http://localhost:15500/assets/index-CrA60y6F.js:40:39748)
    at HS (http://localhost:15500/assets/index-CrA60y6F.js:40:39598)
    at ZR (http://localhost:15500/assets/index-CrA60y6F.js:40:35960)
    at WY (http://localhost:15500/assets/index-CrA60y6F.js:40:34907)
    at x (http://localhost:15500/assets/index-CrA60y6F.js:25:1550)
```

**To Reproduce**
Steps to reproduce the behavior, including example Promptfoo configurations if applicable:

1. Create a config with transformVars that returns a nested object, like this
```
defaultTest:
  options:
    transformVars: |
        return {...vars,
          ctx: {foo:'bar'}
          };
```
3. Run the eval
4. Open web UI
5. See error

**Expected behavior**
No error

**Screenshots**
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/0db24388-d2c1-4ed3-a5d3-cc430199b21a" />

**System information:**

If possible, please output the results of `promptfoo debug` and paste the output here.

{
  "version": "0.103.8",
  "platform": {
    "os": "darwin",
    "release": "23.3.0",
    "arch": "arm64",
    "nodeVersion": "v20.17.0"
  },
  "env": {},
  "configInfo": {
    "configExists": false,
    "configContent": null
  }
}



Apologies - fixed the original comment properly.

I cannot reproduce the issue in the remote web UI when shared: https://app.promptfoo.dev/eval/f:2db828cc-c8bf-4041-9912-74b4e877a4bc/

Can only reproduce in 0.103.8. 0.103.7 works fine.

I'm pretty sure this is where the problem comes from: [it tries rendering the object](https://github.com/promptfoo/promptfoo/commit/49bdcba4251b4766188493fa0c002214eec2c890), while [TruncatedText used to JSONify it](https://github.com/promptfoo/promptfoo/blob/49bdcba4251b4766188493fa0c002214eec2c890/src/app/src/pages/eval/components/TruncatedText.tsx#L66)

Thanks for catching this @sbichenko and thanks @mldangelo for the fix

Hey @mldangelo! Long time no chat :)

Our team is still running into a similar issue on `0.103.10`. Confirmed we don't have this issue for `0.103.7`, but we do for every version after.

Our error: https://react.dev/errors/31?invariant=31&args%5B%5D=object%20with%20keys%20%7Broutes%7D

<img width="1912" alt="Image" src="https://github.com/user-attachments/assets/6f180215-4034-4537-a63e-67d3dc725611" />

An example with a config we can reproduce with (let me know if more granular info would be helpful)
```
prompts:
- ' '
providers:
- id: python:some_provider.py
  label: Some Provider
description: Some Provider Test
defaultTest:
  vars:
    var1: hey
    var2: hi
  assert:
  - type: python
    value: file://asserts/some_provider.py
tests:
  - vars:
      expected:
        routes: ['some_path']
      instruction: where can I find some docs
```

### Promptfoo debug
```
{
  "version": "0.103.10",
  "platform": {
    "os": "darwin",
    "release": "24.2.0",
    "arch": "arm64",
    "nodeVersion": "v20.12.2"
  },
  "env": {},
  "configInfo": {
    "configExists": false,
    "configContent": null
  }
}
```

Let me know if more info is useful!