Skip to content

Added datarobot alias#397

Open
carsongee wants to merge 2 commits intodatarobot-oss:mainfrom
carsongee:carsongee/add_alias
Open

Added datarobot alias#397
carsongee wants to merge 2 commits intodatarobot-oss:mainfrom
carsongee:carsongee/add_alias

Conversation

@carsongee
Copy link
Contributor

@carsongee carsongee commented Mar 12, 2026

RATIONALE

Added datarobot as a command alias after hearing an AI call it d-rocter for the last time 😆

CHANGES

Added support for alias commands, and install the datarobot alias for all systems and ensured completions works

image

Note

Medium Risk
Medium risk because it changes installer/uninstaller behavior across multiple shells and platforms (creating/removing alias binaries and modifying completion/profile files), which can impact user environments if paths or markers are wrong.

Overview
Adds a first-class datarobot alias for the dr CLI across distribution paths (curl install scripts, Windows installer, and Homebrew cask) by creating a symlink/hardlink alongside the primary binary.

Updates completion install/uninstall flows to also generate and remove completions for alias names (Zsh/Bash/Fish plus PowerShell profile blocks), including more granular PowerShell detection/appending and alias-aware removal markers.

Extends smoke tests to assert the datarobot alias exists and produces the same basic output as dr, and updates uninstall tests/logic to account for the additional completion files.

Written by Cursor Bugbot for commit 51db951. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

🔐 Smoke tests approved by maintainer

⏳ Running security scans before executing smoke tests with secrets...

A maintainer has approved this fork PR to run smoke tests. Security scans will run first.

@github-actions
Copy link
Contributor

Some smoke tests failed. (Fork PR)

✅ Security Scan: success
❌ Linux: failure
✅ Windows: success

View run details

func missingPowerShellBlocks(existingContent string) string {
var script string

if !strings.Contains(existingContent, version.CliName+" completion powershell") {
Copy link

Choose a reason for hiding this comment

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

Main PowerShell block detection has false positive from alias

Low Severity

The idempotency check in missingPowerShellBlocks uses strings.Contains(existingContent, version.CliName+" completion powershell") to detect whether the main completion block is already installed. However, the alias block's body also contains the string "dr completion powershell" (in the Invoke-Expression line). If the main block is ever removed while the alias block remains, this check falsely concludes the main block still exists, preventing it from being re-added. The alias block check at line 463 correctly uses the unique marker "# datarobot alias completion", but the main block check lacks similar specificity — it could use "# " + version.CliName + " completion" instead.

Fix in Cursor Fix in Web

Copy link
Contributor

@ajalon1 ajalon1 left a comment

Choose a reason for hiding this comment

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

Is this going to work with Homebrew installs, then?

@carsongee
Copy link
Contributor Author

Is this going to work with Homebrew installs, then?

@ajalon1 I think https://github.com/datarobot-oss/cli/pull/397/changes#diff-b29ed83747f43cc9c81631fead08e0867c73166e8e841b655ee92bcd2f54596dR85 should make that work 🤞

@carsongee carsongee force-pushed the carsongee/add_alias branch from 02bad48 to 51db951 Compare March 12, 2026 20:42
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

fmt.Fprintf(&sb, "if (Get-Command %s -ErrorAction SilentlyContinue) {\n", alias)
fmt.Fprintf(&sb, " %s completion powershell | Out-String | Invoke-Expression\n", version.CliName)
sb.WriteString("}\n")
}
Copy link

Choose a reason for hiding this comment

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

PowerShell alias completion registers for wrong command name

Medium Severity

The PowerShell alias completion block runs dr completion powershell | Out-String | Invoke-Expression, which calls GenPowerShellCompletionWithDesc under the hood. Cobra generates Register-ArgumentCompleter -Native -CommandName 'dr' based on Root().Name() (derived from Use: "dr"), so completions are only registered for dr, never for datarobot. The other shells handle this correctly — bash uses complete -F __start_dr datarobot, fish uses complete --command datarobot --wraps dr, and zsh creates a _datarobot file delegating to _dr — but PowerShell has no equivalent mapping for the alias command name.

Fix in Cursor Fix in Web

continue
}

$isMarker = ($line -match "# $BINARY_NAME completion") -or ($line -match "# .+ alias completion")
Copy link

Choose a reason for hiding this comment

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

Overly broad regex matches unrelated PowerShell profile content

Medium Severity

The marker detection regex "# .+ alias completion" matches any line containing that pattern (e.g., # git alias completion or # my custom alias completion), not just lines written by this tool. The equivalent Go function isCompletionMarker correctly checks for specific alias names from version.CliAliases. This mismatch means the PowerShell uninstaller could accidentally delete unrelated blocks from the user's profile by skipping 3 lines after a false-positive match.

Fix in Cursor Fix in Web

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