Skip to content

fix(auth): say when auth login writes a project .dtctl.yaml - #910

Merged
discostu105 merged 2 commits into
Dynatrace:mainfrom
VfourTwenty:fix/824-auth-login-local-notice
Dec 5, 2026
Merged

discostu105 merged 2 commits into
Dynatrace:mainfrom
VfourTwenty:fix/824-auth-login-local-notice

Conversation

@VfourTwenty

Copy link
Copy Markdown
Contributor

Description

ctx set and config set-credentials warn when their write lands in an auto-discovered .dtctl.yaml, but auth login writes the same file and says nothing about it. Now it prints the same warning after the save, for both the browser and the client credentials grant.

  • Moved the two print lines into warnLocalWrite(ctx, what, path, rerun). warnLocalWriteTarget calls it with the old --global hint, so ctx set and config set-credentials print exactly what they printed before
  • Called it in auth login after the save, only when the config it loaded was auto-discovered
  • No notice when the file comes from --config or DTCTL_CONFIG, or when login writes the global config

Two things differ from calling warnLocalWriteTarget as is:

  1. the hint says Log in with --config <global config path> to write there. instead of Re-run with --global, since auth login has no --global (dtctl auth login --global fails with unknown flag --global). --config is also how the login output and docs/CONFIGURATION.md already point at the global config
  2. it names configPath, the file login picked before the browser wait and wrote back (auth login saves the config it read before the browser wait #822). i didn't search for a .dtctl.yaml again because that search could name a file the login didn't write

went with this hint wording to match the existing --config mentions, can switch to something like "run it outside the project directory" if that reads better)

Related Issues

Closes #824

Testing

Added TestAuthLogin_SaysItWroteTheProjectConfig. It runs auth login in a temp project directory with a real .dtctl.yaml and global config, for the browser and the client credentials grant (IdP, token endpoint and keyring stubbed), and checks stderr for the notice with the file path and the --config hint + that the global config stays untouched. With DTCTL_CONFIG pointing at the same file there's no notice. The two discovered-file cases fail on main.

  • Tests pass (make test)
  • Linting passes (make lint)

@VfourTwenty
VfourTwenty requested review from a team and discostu105 as code owners December 5, 2026 16:58
auth login in a project directory is mostly a token refresh of a context
the .dtctl.yaml already holds. Warn only when the login adds the context
or changes its environment, token-ref or safety level.
@discostu105

Copy link
Copy Markdown
Member

Thanks, the gating on IsLocal() and reusing configPath from before the browser wait both check out.

One change pushed (2929a26): auth login in a project directory is mostly a token refresh of a context the .dtctl.yaml already holds, and warning on every refresh is noise. The notice now fires only when the login adds the context or changes its environment, token-ref or safety level. The test now covers new context / changed environment / refresh / DTCTL_CONFIG for both grants. The refresh case fails without the gate.

@discostu105
discostu105 merged commit b23f7ae into Dynatrace:main Dec 5, 2026
18 checks passed
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.

auth login rewrites a project .dtctl.yaml without the notice that ctx set prints

2 participants