Repository: promptfoo/promptfoo
Issue: Cannot define useHttps with a variable
Root cause: Validation Gap

I can not define `useHttps` with a variable that takes a boolean value (true | false)

**To Reproduce**
1. Define a red team configuration with a raw HTTP target and set the property useHttps to take a variable:

```
targets:
  - id: 'http'
    config:
      useHttps: {{targetUseHttps}}
      request: |
        POST /v1/chat HTTP/1.1
        Host: {{targetHostAndPort}}
        Content-Type: application/json

        {
          "prompt": "{{prompt}}",
        }

...

defaultTest:
  vars:
    targetUseHttps: false
    targetHostAndPort: 'localhost:5000'
```

2. Now run `promptfoo generate`
3. There is an error:
```
C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\node_modules\zod\lib\types.js:55
                const error = new ZodError_1.ZodError(ctx.common.issues);
                              ^

ZodError: [
  {
    "code": "invalid_type",
    "expected": "boolean",
    "received": "object",
    "path": [
      "useHttps"
    ],
    "message": "Expected boolean, received object"
  }
]
    at get error (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\node_modules\zod\lib\types.js:55:31)
    at ZodObject.parse (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\node_modules\zod\lib\types.js:131:22)
    at new HttpProvider (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\dist\src\providers\http.js:432:56)
    at Object.create (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\dist\src\providers\registry.js:637:20)
    at loadApiProvider (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\dist\src\providers\index.js:61:39)
    at C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\dist\src\providers\index.js:126:24
    at Array.map (<anonymous>)
    at loadApiProviders (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\dist\src\providers\index.js:114:42)
    at resolveConfigs (C:\Users\aaa\AppData\Roaming\npm\node_modules\promptfoo\dist\src\util\config\load.js:512:68)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {    
  issues: [
    {
      code: 'invalid_type',
      expected: 'boolean',
      received: 'object',
      path: [ 'useHttps' ],
      message: 'Expected boolean, received object'
    }
  ],
  addIssue: [Function (anonymous)],
  addIssues: [Function (anonymous)],
  errors: [
    {
      code: 'invalid_type',
      expected: 'boolean',
      received: 'object',
      path: [ 'useHttps' ],
      message: 'Expected boolean, received object'
    }
  ]
}
```

**Expected behavior**
The target should use the variable value "false" (boolean)

- Promptfoo version: 0.106.3

I need this to be able to run tests locally with HTTP and also in an Azure pipeline using HTTPS

Out of curiosity @alex-pollan, why use a `defaultTest` var instead of just setting it to `true` in the target configuration?

@typpo I want to control that value from the CLI. In the Azure pipeline I'd set it to true using the option `---var targetUseHttps=true`

Makes sense?

@typpo  HI i have an issues with my variables substitutions in urls. I see the value for token is not being substituted in the url but if i keep it anywhere else it resolves to token-123. Can you guys help me with generating dynamic url 


# Docs: https://promptfoo.dev/docs/red-team/configuration
description: "My first red team"

targets:
  # Red team targets. To talk directly to your application, use a custom provider.
  # See https://promptfoo.dev/docs/red-team/configuration/#providers
  - id: https
    label: customer-service-chatbot
    config:
      url: 'https://httpbin.org/get?token=${{token}}'
      method: "GET"
      headers: {"Content-Type":"application/json", "auth":"{{token}}"}
      body: { "myPrompt":"{{prompt}}", "key":"{{token}}"}

tests:
  - vars:
      token: token-123

@typpo  I also tried resolving the whole url with a variable, and that also did not work

Hi @sudarshanbadireddi.  Try moving your query  parameter to the queryParams configuration:

```yaml
  config:
    url: 'https://httpbin.org/get'  # Remove ?token=${{token}} from URL
    method: "GET"
    queryParams:
      token: "{{token}}"  # Define parameter here instead
    headers: {"Content-Type":"application/json", "auth":"{{token}}"}
    body: { "myPrompt":"{{prompt}}", "key":"{{token}}"}
```


@typpo  Thanks for the response. The queryParams worked. what if i need it as part of the url , like a pathparameter


@sudarshanbadireddi Thanks for flagging. https://github.com/promptfoo/promptfoo/pull/3525 should fix and will be in next release.