Skip to content

Swarm Settings don't reset to default value correctly #4553

Closed

Description

@d4rky-pl

To Reproduce

  1. Create an application
  2. Go to Advanced -> Cluster Settings and press Swarm Settings
  3. Add the command, input anything as timeouts and retries
  4. Save
  5. Refresh the page and reopen Cluster Settings
  6. Clear all values and Save
  7. Refresh the page and reopen Cluster Settings

Current vs. Expected behavior

Instead of inputs being empty and placeholder values being stored all timeouts are stored as 0. Additionally test command is stored as [] which is not the same as "no value" and results in the container being stuck in Starting state.

The only way to recover from this is to either recreate the application or catch the network request happening on Save and clearing healthCheckSwarm.

Provide environment information

Dokploy version: v0.29.7

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

Docker

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

Same server where Dokploy is installed

Additional context

No response

Will you send a PR to fix it?

No

Activity

  1. dosubot commented on Jun 5, 2026

    @dosubot

    Hi @d4rky-pl! I'm Dosu and I'm helping the Dokploy team.

    The root cause is in the Zod schema used by the health check form. The schema uses z.coerce.number() for the numeric fields (Interval, Timeout, StartPeriod, Retries), which converts empty strings (what HTML5 number inputs produce when cleared) to 0 instead of undefined [1].

    This breaks the form's existing hasAnyValue detection logic [2]:

    const hasAnyValue =
      (formData.Test && formData.Test.length > 0) ||
      formData.Interval !== undefined ||
      formData.Timeout !== undefined ||  // This is 0 (truthy check passes) instead of undefined
      formData.StartPeriod !== undefined ||
      formData.Retries !== undefined;

    Since the coerced 0 values pass the !== undefined checks, the form sends { Timeout: 0, Test: [], ... } to the database instead of null (which would clear the configuration entirely).

    Suggested fix — replace z.coerce.number() with a transform that treats empty strings as undefined:

    const optionalNumber = z
      .union([z.string(), z.number()])
      .transform((val) => (val === "" ? undefined : Number(val)))
      .optional();
    
    export const healthCheckFormSchema = z.object({
      Test: z.array(z.string()).optional(),
      Interval: optionalNumber,
      Timeout: optionalNumber,
      StartPeriod: optionalNumber,
      Retries: optionalNumber,
    });

    This preserves the existing hasAnyValue logic and correctly results in null being sent to the API when all fields are cleared. The file to modify is apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/health-check-form.tsx [3].

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dokploy Share Dosu with your team

  2. added a commit that references this issue on Jun 6, 2026
    57ef96a
  3. added a commit that references this issue on Jun 8, 2026
    b3c2e1e
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