Skip to content

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

Closed

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

Activity

  1. dosubot commented on Apr 21, 2026

    @dosubot

    Hi @qveys! I'm Dosu and I’m helping the dokploy team.

    You've correctly identified the root cause. The configFiles field is marked as .optional() in the Zod schema [1], and when the AI SDK converts this to a JSON Schema for OpenAI's response_format, the field gets excluded from the required array — which OpenAI's strict structured output mode rejects.

    The fix would be to change configFiles from .optional() to .nullable() with a .default(null) or simply make it a required field defaulting to an empty array. For example:

    // Option 1: nullable (generates anyOf with null type, satisfying strict mode)
    configFiles: z
      .array(
        z.object({
          content: z.string(),
          filePath: z.string(),
        }),
      )
      .nullable(),
    
    // Option 2: required with empty array as the expected default
    configFiles: z.array(
      z.object({
        content: z.string(),
        filePath: z.string(),
      }),
    ),

    Option 2 is simpler and would also require no changes downstream since configFiles is already handled with optional chaining in the UI components (from PR #2653). You'd just get an empty array instead of undefined.

    This was introduced during the migration from generateObject to generateText with Output.object() in PR #3718, which may have changed how the schema gets serialized to OpenAI's format.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dokploy with Dosu Add Dosu to your team

  2. Xariif commented on May 21, 2026

    @Xariif

    It was fixed? Problem still occures for me - v0.29.4 gpt-4-turbo

  3. ikaddabet commented on May 25, 2026

    @ikaddabet

    Problem still occures for me - v0.29.5 gpt-4o

  4. added a commit that references this issue on Jul 5, 2026
    3e11c0a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions