[CFX-4964] Create/Edit drconfig.yaml only after valid API key received#418
Merged
taras-pokornyy merged 8 commits intodatarobot-oss:mainfrom Apr 8, 2026
Conversation
ajalon1
requested changes
Apr 6, 2026
Contributor
ajalon1
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Chris Russell-Walker <c.russell.walker@gmail.com>
c-h-russell-walker
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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
SetURLToConfigfunction ininternal/config/api.goSetURLToConfigfunction instead ofSaveURLToConfig:--
cmd/auth/login/cmd.go--
cmd/auth/seturl/cmd.go--
internal/auth/auth.goIMPORTANT
SaveURLToConfigfunction still exists as it is used incmd/templates/setup/model.goPR Automation
Comment-Commands: Trigger CI by commenting on the PR:
/trigger-smoke-testor/trigger-test-smoke- Run smoke tests/trigger-install-testor/trigger-test-install- Run installation testsLabels: Apply labels to trigger workflows:
run-smoke-testsorgo- Run smoke tests on demand (only works for non-forked PRs)Important
For Forked PRs: If you're an external contributor, the
run-smoke-testslabel 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.yamlduring 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 loginanddr auth set-urlnow call the newconfig.SetURLToConfighelper, which updates the in-memory Viper config with a normalized endpoint (/api/v2) without writingdrconfig.yamluntil the auth flow completes successfully.auth.WriteConfigFileSilentnow 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 newinternal/config/api_test.gosuite covering URL normalization (including shortcuts) and assertingSetURLToConfigdoes not write to disk.Reviewed by Cursor Bugbot for commit 6903596. Bugbot is set up for automated code reviews on this repo. Configure here.