Skip to content

Bug: v0.2.8 npm package missing environment selection for app create — stale dist published #35

@mjafartp

Description

@mjafartp

Bug: v0.2.8 npm package missing environment selection for app create — stale dist published

Description

The app create command in the published npm package @dokploy/cli@0.2.8 does not include the environment selection logic, even though the source code on main does (commit 68786fb). This causes a 400 Bad Request error when creating an application, because environmentId is never sent in the API payload.

The Dokploy server API (application.create) requires environmentId as a mandatory field, but the published CLI binary never prompts for it and never sends it.

Root Cause

The dist/ folder that was published to npm was built before the environment selection commits were added. The version was bumped to 0.2.8 in the same batch of commits (2647a59), but the compiled JS in the published tarball does not reflect the source changes.

Evidence — published dist/commands/app/create.js in npm package:

  • ❌ No environmentId flag defined
  • ❌ No environment selection prompt
  • ❌ API payload only sends { name, appDescription, appName, projectId } — missing environmentId

Source on main (src/commands/app/create.ts):

  • ✅ Has environmentId flag (line 25-29)
  • ✅ Has environment selection prompt (lines 82-100)
  • ✅ API payload includes environmentId (line 162)

Steps to Reproduce

  1. Install the CLI: npm install -g @dokploy/cli@0.2.8
  2. Authenticate: dokploy authenticate
  3. Run: dokploy app create
  4. Select a project, enter app name, confirm creation
  5. Result: Error: Error creating application: Request failed with status code 400

The server responds with:

{
  "message": "Input validation failed",
  "code": "BAD_REQUEST",
  "data": {
    "zodError": {
      "fieldErrors": {
        "environmentId": ["Invalid input: expected string, received undefined"]
      }
    }
  }
}

Expected Behavior

  • The CLI should prompt the user to select an environment (if the project has multiple environments) or auto-select if there's only one
  • The environmentId should be included in the API request payload
  • Application should be created successfully

Suggested Fix

  1. Rebuild and republish — run the build step before publishing to npm so the dist matches the source on main
  2. (Optional improvement) Auto-select the environment when a project has only one, and only prompt when there are multiple:
if (!environmentId) {
    if (!selectedProject?.environments || selectedProject.environments.length === 0) {
        this.error(chalk.yellow("No environments found in this project."));
    }

    if (selectedProject.environments.length === 1) {
        environmentId = selectedProject.environments[0].environmentId;
        this.log(chalk.dim(`  Auto-selected environment: ${selectedProject.environments[0].name}`));
    } else {
        const { environment } = await inquirer.prompt([
            {
                choices: selectedProject.environments.map((env) => ({
                    name: `${env.name}${env.description ? ` (${env.description})` : ''}`,
                    value: env,
                })),
                message: "Select an environment:",
                name: "environment",
                type: "list",
            },
        ]);
        environmentId = environment.environmentId;
    }
}

Environment

  • CLI version: @dokploy/cli v0.2.8 (npm)
  • OS: Linux / macOS
  • Node: v18+
  • Dokploy server: Latest

Areas Affected

  • app create command (interactive mode)
  • npm publish pipeline

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions