Skip to content

[CFX-4964] Create/Edit drconfig.yaml only after valid API key received#418

Merged
taras-pokornyy merged 8 commits intodatarobot-oss:mainfrom
taras-pokornyy:pokorny/CFX-4964-edit-drconfig-yaml-after-API-token-ready
Apr 8, 2026
Merged

[CFX-4964] Create/Edit drconfig.yaml only after valid API key received#418
taras-pokornyy merged 8 commits intodatarobot-oss:mainfrom
taras-pokornyy:pokorny/CFX-4964-edit-drconfig-yaml-after-API-token-ready

Conversation

@taras-pokornyy
Copy link
Copy Markdown
Contributor

@taras-pokornyy taras-pokornyy commented Apr 3, 2026

RATIONALE

Don't touch ~/.config/datarobot/drconfig.yaml until both valid endpoint AND token are ready when running dr auth login. So unfinished auth flow won't break anything.

Actual:

When running dr auth login, the CLI will write to ~/.config/datarobot/drconfig.yaml a set of credentials before the auth flow is complete.

Expected:

When running dr auth login, the CLI will write to ~/.config/datarobot/drconfig.yaml the set of credentials ONLY once auth flow is complete and successful.

CHANGES

  • Created SetURLToConfig function in internal/config/api.go
  • Updated following files to use new SetURLToConfig function instead of SaveURLToConfig:
    -- cmd/auth/login/cmd.go
    -- cmd/auth/seturl/cmd.go
    -- internal/auth/auth.go

IMPORTANT

SaveURLToConfig function still exists as it is used in cmd/templates/setup/model.go

PR Automation

Comment-Commands: Trigger CI by commenting on the PR:

  • /trigger-smoke-test or /trigger-test-smoke - Run smoke tests
  • /trigger-install-test or /trigger-test-install - Run installation tests

Labels: Apply labels to trigger workflows:

  • run-smoke-tests or go - Run smoke tests on demand (only works for non-forked PRs)

Important

For Forked PRs: If you're an external contributor, the run-smoke-tests label won't work. A maintainer must manually trigger the "Fork PR Smoke Tests" workflow from the Actions tab, providing your PR number. Please comment requesting a maintainer review if you need smoke tests to run.


Note

Medium Risk
Changes when the CLI mutates and writes drconfig.yaml during authentication, which can affect users’ ability to log in and persist credentials if there are edge-case failures. The scope is contained to URL-setting and config-write helpers, with added tests to reduce regression risk.

Overview
Defers config-file writes during auth URL setup. dr auth login and dr auth set-url now call the new config.SetURLToConfig helper, which updates the in-memory Viper config with a normalized endpoint (/api/v2) without writing drconfig.yaml until the auth flow completes successfully.

auth.WriteConfigFileSilent now ensures the config directory/file exists before writing, and the interactive URL prompt messaging is updated to reflect that validation/API-key retrieval happens next. Adds a new internal/config/api_test.go suite covering URL normalization (including shortcuts) and asserting SetURLToConfig does not write to disk.

Reviewed by Cursor Bugbot for commit 6903596. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@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 1 potential issue.

Fix All in Cursor

@ajalon1 ajalon1 requested a review from a team April 3, 2026 15:13
@ajalon1 ajalon1 self-assigned this Apr 3, 2026
Copy link
Copy Markdown
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.

Requesting changes to make sure that we handle all scenarios where we write to config. Good first pass.

I'd also suggest writing unit tests for SetUrlToConfig(), and ensure that the config file is NOT written to.

taras-pokornyy and others added 2 commits April 7, 2026 17:15
Co-authored-by: Chris Russell-Walker <c.russell.walker@gmail.com>
Copy link
Copy Markdown
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.

🚢

@taras-pokornyy taras-pokornyy merged commit c3bc337 into datarobot-oss:main Apr 8, 2026
13 checks passed
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.

3 participants