Skip to content

fix: Accept --session on plugin commands - #305

Merged
scotwells merged 1 commit into
feat/302-session-overridefrom
fix/304-session-flag-after-plugin-name
Oct 1, 2026
Merged

scotwells merged 1 commit into
feat/302-session-overridefrom
fix/304-session-flag-after-plugin-name

Conversation

@scotwells

Copy link
Copy Markdown
Contributor

Fixes #304

datumctl assistant card --session swells@datum.net@api.datum.net failed with patch: unknown flag: --session. Only a --session placed before the plugin name was consumed by datumctl; put anywhere else it was forwarded to the plugin as one of its own arguments. The error named the plugin rather than datumctl, and the workaround was to switch the active session — the thing the flag exists to avoid.

You can now put --session where you'd naturally put it:

datumctl assistant card --session swells@datum.net@api.staging.env.datum.net
datumctl dns zones list --session alice@example.com@api.datum.net

datumctl takes the flag out of the command line wherever it appears and turns it into the DATUM_SESSION and API host the plugin already understands. Arguments after a bare -- are still the plugin's to interpret. The same handling now applies to a plugin's shell completion and --help.

Also: --session with no value fails with datumctl's own "needs a session name" message instead of clearing the override and quietly running as the active session.

Precedence

--session beats DATUM_SESSION, unchanged from the root command and from what the flag's own help says. A bad --session value fails immediately; DATUM_SESSION is still resolved lazily, so a stale export only breaks commands that actually need a session.

Scope

Narrowed deliberately to --session. The other global flags a plugin doesn't parse are not in the same class: plugins define their own --project, --org and -o (the assistant plugin does), so consuming those at the datumctl layer would break them. --session is the one flag datumctl owns end to end and no plugin defines.

Base

Stacked on #303 (feat/302-session-override), which introduces the global --session flag. There is nothing to fix on main — the flag doesn't exist there yet. Retarget to main once #303 lands.

Verified

  • go build ./..., go vet ./..., go test ./... clean.
  • New tests in internal/plugindispatch/session_override_test.go cover the flag after the plugin name, --session=, the -- boundary, the missing-value error, and a fake managed plugin asserting the argv and DATUM_SESSION/DATUM_API_HOST it receives. They fail on the parent branch and pass here.
  • Manually, against the real assistant plugin: the flag after the subcommand prints the agent card, and pointing it at staging vs production actually changes the endpoint the plugin talks to (patch.staging.env.datum.net vs patch.datum.net), so the session is taking effect and not just being dropped. Also checked flag-beats-env, unknown session, ambiguous email, missing value, --help, and -o json still reaching the plugin.

🤖 Generated with Claude Code

"datumctl <plugin> <subcmd> --session X" failed with the plugin's own
"unknown flag: --session", because only a --session placed before the
plugin name was consumed by datumctl; anywhere else it was forwarded as
one of the plugin's arguments. That pointed users at the wrong component
and pushed them toward switching their active session instead, which is
exactly what the flag exists to avoid.

datumctl now takes --session out of a plugin command line wherever it
appears and turns it into the DATUM_SESSION (and API host) the plugin
already understands. Arguments after a bare "--" still belong to the
plugin. The flag continues to beat DATUM_SESSION, and --session with no
value now fails with datumctl's own message rather than quietly running
as the active session.

Fixes #304

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@scotwells
scotwells merged commit 4ff80de into feat/302-session-override Oct 1, 2026
2 checks passed
@scotwells
scotwells deleted the fix/304-session-flag-after-plugin-name branch October 1, 2026 21:46
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