Skip to content

Fix CLI help grammar and the privileged-switch cancellation message - #17402

Closed
Anshuman-Prakash wants to merge 1 commit into
elastic:mainfrom
Anshuman-Prakash:fix/text-auditor-14861-cli
Closed

Anshuman-Prakash wants to merge 1 commit into
elastic:mainfrom
Anshuman-Prakash:fix/text-auditor-14861-cli

Conversation

@Anshuman-Prakash

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the CLI text defects reported in #14861 — items 1 through 4 of that issue.

The one that is more than a typo (item 2) — internal/pkg/agent/cmd/privileged.go:

// in privilegedCmd(), when the user declines the confirmation prompt
-   return fmt.Errorf("unprivileged switch was cancelled by the user")
+   return fmt.Errorf("privileged switch was cancelled by the user")

This sits in the privileged command's own prompt handler, so declining elastic-agent privileged told the user their unprivileged switch had been cancelled — the opposite of the operation they had just aborted. The matching line in unprivileged.go is correct and is left alone.

Item 1 — the same grammar error in both privilege-switch long descriptions (privileged.go, unprivileged.go):

Before After
By default this command will ask or a confirmation before making this change. By default this command will ask for confirmation before making this change.

Items 3 and 4 — internal/pkg/agent/cmd/container.go help text:

Before After
FLEET_CA - path to certificate authority to use with communicate with Fleet Server ... to certificate authority to communicate with Fleet Server
KIBANA_FLEET_CA - path to certificate authority to use with communicate with Kibana ... to certificate authority to communicate with Kibana
KIBANA_CA - path to certificate authority to use with communicate with Kibana ... to certificate authority to communicate with Kibana
ELASTIC_AGENT_CERT_KEY - path to private key use for connecting to fleet-server. ... path to private key to use for connecting to fleet-server.

Item 5 of the issue (an contrib → a contrib in the EDOT authentication docs) is documentation, so it is in a separate docs-only PR, #17401. This PR is therefore marked "Relates to" rather than "Closes", so the issue stays open until both land.

Why is it important?

Item 2 is actively misleading: a user who aborts a switch to privileged mode is told the opposite switch was cancelled, which is the sort of thing that sends someone checking whether their agent is now in the wrong mode. The rest is help text shown by elastic-agent container --help, which is the reference operators read when wiring up the container image's environment variables.

Checklist

  • My code follows the style guidelines of this project
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

A bug-fix fragment is included for the cancellation message, since that one is user-visible behaviour rather than prose. The help-text changes on their own would not warrant a changelog entry.

No test is added: the changed strings are a cobra Long description and two fmt.Errorf messages with no existing assertions against them (searching *_test.go for switch was cancelled, ask or a confirmation and use with communicate returns nothing), and the prompt path requires an interactive terminal.

Disruptive User Impact

None functionally — only the text of one error message and some help output changes. Anyone matching on the exact string unprivileged switch was cancelled by the user to detect a cancelled privileged switch would need to update, but that string was wrong for that case to begin with.

How to test this PR locally

elastic-agent privileged        # decline the prompt; the error now says "privileged switch was cancelled by the user"
elastic-agent privileged --help # "will ask for confirmation"
elastic-agent container --help  # the four CA/cert-key lines above

gofmt -l reports no changes needed on the three edited files. I was not able to compile the packages locally: this checkout's beats submodule is not initialised, so the ./beats replace directive makes go build ./internal/... fail before reaching these files. The edits are string-literal only, so I have left compilation and the unit suite to CI rather than claiming a local build.

Related issues

🤖 Generated with Claude Code

The privileged command reported "unprivileged switch was cancelled by
the user" when its own confirmation prompt was declined, naming the
opposite mode. Also fix "ask or a confirmation" in both privilege-switch
long descriptions and four container help strings.

Relates to elastic#14861

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mergify

mergify Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label. Could you fix it @Anshuman-Prakash? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@Anshuman-Prakash

Copy link
Copy Markdown
Contributor Author

Superseded by #17803, which consolidates this into one PR per @bmorelli25's request.

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.

1 participant