Skip to content

fix: Pick a session by endpoint in auth switch - #301

Merged
scotwells merged 2 commits into
mainfrom
fix/277-auth-switch-endpoint
Sep 25, 2026
Merged

scotwells merged 2 commits into
mainfrom
fix/277-auth-switch-endpoint

Conversation

@scotwells

@scotwells scotwells commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When one email is signed in to production and staging, switching accounts always opened a picker, so a script, CI job or agent had no way to choose between them.

You can now name the environment with --endpoint, using the value datumctl auth list prints, or pass the full session name:

$ datumctl auth list
User              Endpoint                   Status
swells@datum.net  api.datum.net              Active
swells@datum.net  api.staging.env.datum.net

$ datumctl auth switch swells@datum.net --endpoint api.staging.env.datum.net
✓ Switched to Scot Wells (swells@datum.net)
  Context:  datum
  Endpoint: api.staging.env.datum.net

Without a terminal, an ambiguous switch tells you exactly what to run instead of failing with no way forward:

$ datumctl auth switch swells@datum.net
error: swells@datum.net is signed in on more than one endpoint. Choosing one interactively requires a terminal.
Run one of:
  datumctl auth switch swells@datum.net --endpoint api.datum.net
  datumctl auth switch swells@datum.net --endpoint api.staging.env.datum.net

$ datumctl auth switch swells@datum.net --endpoint api.nope.example
error: No session for swells@datum.net on endpoint api.nope.example.
Signed-in endpoints: api.datum.net, api.staging.env.datum.net

In a terminal the picker works as before, and when datumctl ctx use points you at a context in your other environment, its suggested switch command now includes the endpoint.

Test plan

  • An email on two endpoints switches to each by endpoint and back, and the active context follows every time
  • An unknown endpoint fails and lists the endpoints you are signed in on
  • With no terminal, an ambiguous switch lists one runnable command per session
  • Switching leaves your other sessions signed in

Fixes #277

🤖 Generated with Claude Code

scotwells and others added 2 commits September 25, 2026 13:59
When one email is signed in on two endpoints, such as production and
staging, 'datumctl auth switch <email>' always opened the picker. With
no terminal it failed with a hint to name the email and endpoint, but
nothing accepted an endpoint, and the full session name was rejected
too. Scripts and CI had no way to switch between the two.

'auth switch' now accepts the full session name and an --endpoint flag
that takes the endpoint 'auth list' prints, with or without a scheme
or trailing slash. An endpoint with no session fails and lists the
endpoints that exist. Without a terminal, an ambiguous switch prints
the exact command for each matching session, and the no-argument case
no longer says "for this email". The 'ctx use' hint for a context in
another session includes --endpoint when the email needs it.

Fixes #277

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The hint listing signed-in endpoints read as if it scoped to one
email even when no email was given, since the wording did not change
for the all-accounts case. State plainly that the list spans any
account when no email narrows it, and cover the case with a test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@scotwells
scotwells marked this pull request as ready for review September 25, 2026 19:06
@scotwells
scotwells enabled auto-merge September 25, 2026 19:06
@scotwells
scotwells requested review from a team and ecv September 25, 2026 19:10
@scotwells
scotwells merged commit 141374a into main Sep 25, 2026
2 checks passed
@scotwells
scotwells deleted the fix/277-auth-switch-endpoint branch September 25, 2026 19:13
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.

Switching between same-email sessions cannot be scripted

2 participants