Skip to content

[BUG] AI Assistant fails with "Invalid schema for response_format": Missing 'configFiles' in required array #4267

@qveys

Description

@qveys

To Reproduce

  1. Go to any project environment in Dokploy
  2. Click "AI Assistant" to create a custom template
  3. Fill in your needs in Step 1 and proceed to Step 2
  4. The error appears immediately at Step 2 "Choose a Variant"

Error message:

Invalid schema for response_format 'response': In context=('properties', 'suggestions', 'items'), 'required' is required to be supplied and to be an array including every key in properties. Missing 'configFiles'.

Dokploy version: v0.29.1

Current vs. Expected behavior

Current behavior: The AI Assistant fails at Step 2 "Choose a Variant" with a schema validation error. The configFiles field is defined in the suggestions.items.properties of the JSON Schema sent to the OpenAI API as response_format, but it is NOT listed in the required array. Modern OpenAI models (e.g. gpt-4o) enforce strict mode and require ALL properties to be listed in required.

Root cause: In packages/server/src/services/ai.ts, the Zod schema marks configFiles as .optional(), but when converted to JSON Schema for response_format, OpenAI strict mode requires every key in properties to be present in required (with optional fields using anyOf: [{...}, {type: 'null'}] instead).

Expected behavior: The AI Assistant should generate variant suggestions without error.

Provide environment information

Operating System:
  OS: Ubuntu 22.04
  Arch: x64
Dokploy version: v0.29.1
VPS Provider: Hostinger
AI Provider: OpenAI (gpt-4o)
What applications/services are you trying to deploy?
  Any service via AI Assistant template generator

Which area(s) are affected? (Select all that apply)

Application

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

The fix should be in packages/server/src/services/ai.ts. The configFiles field in the fullSchema Zod object is marked as .optional(), but OpenAI strict mode requires all properties to be in required. The fix is to either:

  1. Add configFiles to required and use z.nullable() or anyOf with null type
  2. Or disable strict mode for this specific response_format call

Will you send a PR to fix it?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions