Skip to content

CFX-7958: fix(install): wrong completion command - #884

Open
ajalon1 wants to merge 4 commits into
datarobot-oss:mainfrom
ajalon1:aj/CFX-7958-completion-install-hints
Open

CFX-7958: fix(install): wrong completion command#884
ajalon1 wants to merge 4 commits into
datarobot-oss:mainfrom
ajalon1:aj/CFX-7958-completion-install-hints

Conversation

@ajalon1

@ajalon1 ajalon1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
╰─ ❯ dr self update -f                                                                      👾 v0.4.2 👾 staging.dr
    ____        __        ____        __          __
   / __ \____ _/ /_____ _/ __ \____  / /_  ____  / /_
  / / / / __ `/ __/ __ `/ /_/ / __ \/ __ \/ __ \/ __/
 / /_/ / /_/ / /_/ /_/ / _, _/ /_/ / /_/ / /_/ / /_
/_____/\__,_/\__/\__,_/_/ |_|\____/_.___/\____/\__/

==> Installing DataRobot CLI

  → Detected platform: Darwin arm64
  → Fetching latest version...
   Version: v0.4.3
  → Current installation: v0.4.2
  → Target version: v0.4.3
==> Update available: v0.4.2 → v0.4.3
  → Upgrading to: v0.4.3

==> Downloading and installing...
  → Downloading from GitHub...
   https://github.com/datarobot-oss/cli/releases/download/v0.4.3/dr_v0.4.3_Darwin_arm64.tar.gz
######################################################################## 100.0%
  → Extracting binary...
  → Installing binary to /Users/aj.alon/.local/bin/dr...
  → Creating 'datarobot' alias...

==> Installation complete!
  → Verifying installation...
   ✓ DataRobot CLI version: v0.4.3
  → Installation directory is in PATH
  → To install completions, run: dr self completion install --yes

==> Get started by running: dr --help


╭ notebooks on  aj/notebooks-and-workload-api is 📦 v0.1.0 via 🪖  via 🐍 v3.14.6 (notebooks)  u/na took 7s217ms as aj.alon@datarobot.com (AJ Alon) .☸ k3d-nbx in
╰─ ❯ dr self completion install --yes                                                       👾 v0.4.3 👾 staging.dr
→ Detected shell: zsh

✓ Completion already installed at: /Users/aj.alon/.zsh/completions/_dr.

To reinstall, use: dr completion install --force --yes

Note

Low Risk
User-facing CLI messaging and help examples only; no changes to install/uninstall behavior or security-sensitive paths.

Overview
Fixes CFX-7958, where reinstall and dry-run messages suggested dr completion install (and similar) even though the real command is dr self completion install.

Install and uninstall now pass the invoked *cobra.Command into the hint helpers so copy uses cmd.CommandPath() instead of a hardcoded CliName + " completion …" string. Completion generation still uses cmd.Root() where needed. Help examples are updated to show the self completion path.

Tests add a synthetic parent chain (wireCommandPath), stdout capture, and assertions that printed hints match dr self completion install|uninstall ….

Reviewed by Cursor Bugbot for commit 4f19d5b. Configure here.

@ajalon1 ajalon1 changed the title CFX-7958: fix: completion hints missing self prefix CFX-7958: fix(install): wrong completion command Sep 1, 2026
@ajalon1

ajalon1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-install-tests

@ajalon1

ajalon1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

oh actually I think there's a way to read the names from the cobra command tree

…nclude "self"

Every user-facing hint in cmd/self/completion/install/cmd.go and
cmd/self/completion/uninstall/cmd.go (Example blocks, the "already
installed" reinstall hint, and the dry-run hints) told users to run
`dr completion install/uninstall ...`, but those commands only exist
under `dr self completion install/uninstall ...`. Copy-pasting the
hint failed with an unknown-command error. install/cmd.go line 354
already had the correct `self` prefix; the rest did not.

The two runtime-printed hints (reinstall and dry-run, in both files)
now derive their command path from cmd.CommandPath() instead of a
hardcoded string, so they can't silently drift out of sync again if
the command is ever renamed or reparented.
@ajalon1
ajalon1 force-pushed the aj/CFX-7958-completion-install-hints branch from a828d93 to f66e7e8 Compare September 1, 2026 18:09
By default, this command runs in preview mode. Use '--yes' to install directly.`,
Example: ` # Preview what would be installed (default behavior):
` + version.CliName + ` completion install
` + version.CliName + ` self completion install

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about tweaking the Example strings to also use the updated commands, but the strings get registered on the command well before the command gets wired up, so ... I'll take the small loss if we ever have to move self completion again. The more impt thing is taht the actual code is up to date

@ajalon1
ajalon1 marked this pull request as ready for review September 1, 2026 18:24
@ajalon1
ajalon1 requested a review from a team as a code owner September 1, 2026 18:24
@ajalon1

ajalon1 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🔐 Fork PR smoke tests triggered by @ajalon1

⚠️ Security Notice: This will run tests with access to repository secrets.

What happens next:

  1. Security scans will run automatically (Trivy, gosec)
  2. If security scans pass, smoke tests will run
  3. Results will be posted as PR comments

⚠️ Important: Review the PR code carefully before approving!

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Some smoke tests failed. (Fork PR)

❌ Security Scan: failure
❌ Linux: skipped
❌ Windows: skipped

View run details

⚠️ Security vulnerabilities detected! Check the Security tab for details.

@chasdr chasdr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 chasbot here — chas sent me to second-guess whatever your droid shipped, and the audit came back annoyingly boring.

what held up under scrutiny:

  • premise checks out: root_factory.go:390 disables cobra's default completion command, so every hint this fixes really was a dead instruction
  • CommandPath() is the right fix for the two runtime hints — they can't drift again. the Example blocks staying hardcoded is also correct, since they're built before the command is wired to its parents
  • getInstallFunc / installFunc still receive cmd.Root(), so completion generation is untouched
  • the tests wire the real parent chain and assert on rendered output. ran them plus task lint (all three GOOS) locally: green

one thing your droid walked right past — to be fair, so has everyone since completion moved under self, it's pre-existing and not this PR's problem: the powershell installer writes dr completion powershell | Out-String | Invoke-Expression into the user's profile (install/cmd.go L479-L491). the exact disease this PR cures everywhere else, except this copy executes at every powershell startup, so completions never load there at all. not a one-liner either: the already-installed guard and the uninstall detection both match the literal dr completion powershell string, so a fix has to handle old profiles too. follow-up ticket material.

minor: runInstall's doc comment is 5 lines saying the CommandPath rationale twice, and the same rationale repeats in runUninstall and three test comments. chas runs a 2-line comment budget on me — you get it as a suggestion, not a hook.

one dedup nit inline. approving — this stands on its own.

// cmd/self/completion/cmd.go), so cmd.CommandPath() resolves exactly as it
// does at runtime. This package can't import cmd/self/completion directly —
// that package imports this one, so doing so would create an import cycle.
func wireCommandPath(cmd *cobra.Command) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wireCommandPath + captureStdout are byte-identical to the install test's copies, and internal/testutil is already imported here. worth moving them there?

Move shared completion test helpers into internal/testutil and reuse them from install and uninstall tests. Trim repeated CommandPath rationale comments and reuse the existing test home helper in the PowerShell profile test.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@ajalon1

ajalon1 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🔐 Fork PR smoke tests triggered by @ajalon1

⚠️ Security Notice: This will run tests with access to repository secrets.

What happens next:

  1. Security scans will run automatically (Trivy, gosec)
  2. If security scans pass, smoke tests will run
  3. Results will be posted as PR comments

⚠️ Important: Review the PR code carefully before approving!

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Some smoke tests failed. (Fork PR)

❌ Security Scan: failure
❌ Linux: skipped
❌ Windows: skipped

View run details

⚠️ Security vulnerabilities detected! Check the Security tab for details.

Bump golang.org/x/crypto to v0.55.0 to resolve the Trivy finding reported by the fork smoke workflow. go mod tidy also updates golang.org/x/net to v0.57.0.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@ajalon1

ajalon1 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🔐 Fork PR smoke tests triggered by @ajalon1

⚠️ Security Notice: This will run tests with access to repository secrets.

What happens next:

  1. Security scans will run automatically (Trivy, gosec)
  2. If security scans pass, smoke tests will run
  3. Results will be posted as PR comments

⚠️ Important: Review the PR code carefully before approving!

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🔐 Fork smoke tests started by maintainer

⏳ Security scans passed. Running smoke tests...

Commit: 9f1c12dd65f1930ac74faa05d7880e80bdb04079
View run

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

All smoke tests passed! (Fork PR)

✅ Security Scan: success
✅ Linux: success
✅ Windows: success

View run details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants