Skip to content

Fix for ecctl deployment create bug when --version isn't provided#761

Merged
gigerdo merged 3 commits intoelastic:masterfrom
mlliarm:fix-empty-version-issue
Mar 23, 2026
Merged

Fix for ecctl deployment create bug when --version isn't provided#761
gigerdo merged 3 commits intoelastic:masterfrom
mlliarm:fix-empty-version-issue

Conversation

@mlliarm
Copy link
Copy Markdown
Contributor

@mlliarm mlliarm commented Mar 23, 2026

Description

When --version is not provided to ecctl deployment create, the command now automatically fetches the latest available stack version from the API and uses it. This avoids a confusing error when users omit the --version flag.

Key changes in create.go:

  • Added a call to getLatestStackVersion() that queries stackapi.List for available stack versions and picks the first (latest) one.
  • The auto-fetch is skipped when --file is provided, since file-based payloads carry their own version.
  • Prints a message to stderr (--version not set, using latest: X.Y.Z) so the user knows which version was selected.

Related Issues

#756

Motivation and Context

  • Previously, omitting --version could lead to an empty version being passed through the deployment creation flow, resulting in unclear errors or unexpected behavior.
  • This change makes the CLI more user-friendly by defaulting to the latest available stack version, matching user expectations.
  • The --file path is excluded from this behavior since the payload file already specifies its own version.

How Has This Been Tested

  • Added a new test case "succeeds creating a deployment without --version by fetching latest stack version" that mocks the stack versions API returning multiple versions (7.8.0, 7.7.0, 7.6.0), verifies the latest is selected, and asserts the stderr message.
  • All 30 existing and new tests in cmd/deployment/ pass.
  • Test run:
image

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

…--file are empty

Co-authored-by: Claude <noreply@anthropic.com>
@mlliarm mlliarm requested a review from a team as a code owner March 23, 2026 08:20
Co-authored-by: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@gigerdo gigerdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thanks, great addition for creating deployments.

@gigerdo gigerdo merged commit 73e8cf4 into elastic:master Mar 23, 2026
8 checks passed
@mlliarm mlliarm deleted the fix-empty-version-issue branch March 23, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants