Open Studio

KUBB_INVALID_SERVER_VARIABLE: Invalid server variable

The KUBB_INVALID_SERVER_VARIABLE diagnostic, raised when a server URL variable value is not one of the values its enum allows.

Code: KUBB_INVALID_SERVER_VARIABLE Level: error

A server variable resolves to a value that its enum does not allow.

What happened ​

OpenAPI server URLs can contain {variable} placeholders. When a variable declares an enum, the value Kubb resolves it to must be in that list. This diagnostic fires when the resolved value is not.

How to fix it ​

  • Pass a value that the enum allows, or make the default a member of the enum.
  • Add the value to the enum if the server supports it.
  • Remove the enum if the variable is open-ended.

Common causes ​

  • An override passed to Kubb uses a value outside the variable's enum.
  • The variable's default is not itself a member of its enum.
  • The enum list is missing a value that the server actually supports.

Example ​

petStore.yaml
servers: - url: https://{env}.api.example.com variables: env: default: dev enum: [dev, prod] # 'staging' is not allowed

Example output ​

Terminal
[KUBB_INVALID_SERVER_VARIABLE]: Invalid server variable value 'staging' for 'env' when resolving https://{env}.api.example.com. Valid values are: dev, prod. at: #/servers fix: Use one of the allowed enum values, or drop the enum on the 'env' server variable. see: https://kubb.dev/docs/5.x/reference/diagnostics/kubb-invalid-server-variable

See also ​