Skip to content

[AECO-2370] feat(build-studio): export --yes as DATAROBOT_CLI_NON_INTERACTIVE for nested processes - #1104

Draft
Anton Bogatyrov (antonbogatyrov) wants to merge 2 commits into
mainfrom
abogatyrov/AECO-2370-consent-env
Draft

Anton Bogatyrov (antonbogatyrov) wants to merge 2 commits into
mainfrom
abogatyrov/AECO-2370-consent-env

Conversation

@antonbogatyrov

Copy link
Copy Markdown
Contributor

RATIONALE

Part of AECO-2370 (dr build-studio --yes hangs on "Starting OpenCode server…" when OpenCode is not installed).

dr build-studio installs the xp and opencode plugins, but the OpenCode application is installed lazily by the opencode wrapper on its first run — which happens inside dr opencode serve, a grandchild process dr xp spawns headless when the Assist tab opens. The user's --yes never reached that process: the flag cannot be forwarded through xp (it rejects unknown flags), so the wrapper's install prompt ran with no consent and no terminal, read EOF off /dev/null, and died — on every readiness probe.

Design principle agreed on the ticket: consent is converted, never fabricated. Env is the only consent transport that survives the process chain (build-studio → dr xp → dr opencode serve), so build-studio exports the user's explicit --yes as the CLI's standard automation switch.

CHANGES

  • runStudio: when consent was given (-y/--yes, or DATAROBOT_CLI_NON_INTERACTIVE already set by the user), set DATAROBOT_CLI_NON_INTERACTIVE=1 before launching xp. Nested processes inherit it; the opencode wrapper (datarobot/opencode-cli-plugin#76) installs OpenCode without prompting only when it is set.
  • Without --yes nothing is exported — a headless run without consent now fails fast in the wrapper with instructions, which the Assist tab surfaces (datarobot/dr-experimentation-cli#439).
  • Test: the variable is set at xp-exec time with --yes and stays unset without it.

RELATED

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)

🤖 Generated with Claude Code

… nested processes (AECO-2370)

The OpenCode application itself is installed lazily by the opencode
plugin wrapper on its first run — which happens inside `dr opencode
serve`, a grandchild process dr xp spawns headless when the Assist tab
opens. The user's --yes never reached it: the flag cannot be forwarded
(xp rejects flags it does not know), so the wrapper's install prompt ran
with no consent and no terminal.

Convert the consent instead of dropping it: when build-studio runs with
-y/--yes (or the env var already set), export
DATAROBOT_CLI_NON_INTERACTIVE=1 before launching xp. Env is inherited
down the whole chain, and the wrapper (opencode-cli-plugin#76) installs
OpenCode without prompting only when it is set. Consent is converted,
never fabricated: nothing is exported without --yes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@datarobot-pr-review-router

Copy link
Copy Markdown

🎫 AECO-2370 · Bug

dr build-studio --yes hangs on "Starting OpenCode server…" when OpenCode is not installed

How Review Router works

@github-actions github-actions Bot added the go Pull requests that update go code label Nov 20, 2026
… tests

runStudio with --yes sets DATAROBOT_CLI_NON_INTERACTIVE for nested
processes; stubSeams now resets it per test with cleanup, so a consent
granted in one test cannot flip another's expectations under -shuffle.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@ajalon1 AJ Alon (ajalon1) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey Anton Bogatyrov (@antonbogatyrov), just cruising through the open PRs from this week, some thoughts for you on this, but since this is still draft don't consider any of this binding or blocking. Good call on using an env var. The scope is tight and the test covers both the --yes and no---yes cases.

Two small things:

  • I don't like that we are calling os.Setenv to make this happen, since this also mutates the dr process itself. We haven't solved this problem, so you do not need to do anything here. I've filed ALIFE-2020 to address this.
  • The test stubs executePlugin, so it shows the variable is set before exec but not that a real child inherits it. Reading buildPluginEnv confirms it does (os.Environ()), so I'm not asking for more.

Comment thread cmd/build-studio/cmd.go
Comment on lines +175 to +177
if err := os.Setenv(reader.NonInteractiveEnv, "1"); err != nil {
log.Debug("Failed to export non-interactive consent", "error", err)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd return this error rather than log it. If the export ever failed we would be back to the original symptom (consent lost, nested dr opencode serve prompts with no terminal, Assist tab hangs), and the only trace would be a debug line that doesn't say which variable or what it means. cmd/tls.go does the same kind of propagation and returns the error (propagate tls env: %w).

I'd also like to log the successful export. There's no precedent for this yet (tls.PropagateEnv doesn't log either), but nothing in the logs says that dr changed its own environment, which is the first thing I'd want to know when a nested dr unexpectedly skips a prompt. A shared helper for env exports could come later.

Suggested change
if err := os.Setenv(reader.NonInteractiveEnv, "1"); err != nil {
log.Debug("Failed to export non-interactive consent", "error", err)
}
if err := os.Setenv(reader.NonInteractiveEnv, "1"); err != nil {
return 0, fmt.Errorf("export %s for nested plugins: %w", reader.NonInteractiveEnv, err)
}
log.Debug("Exported consent to nested processes", "env", reader.NonInteractiveEnv, "value", "1", "yes_flag", args.yes)

Basically, think about how users might approach this when debugging build-studio gone haywire.

Comment thread cmd/build-studio/cmd.go
Comment on lines +167 to +174
// Export the user's consent so it survives process boundaries: -y
// cannot be forwarded as a flag (xp rejects flags it does not know),
// but env is inherited down the whole chain — dr xp passes it on to
// the `dr opencode serve` subprocess it spawns, whose wrapper
// installs OpenCode without prompting only when this is set
// (AECO-2370). Consent is converted here, never fabricated: the
// variable is set only when the user passed -y/--yes or already set
// it themselves.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small wording suggestion for this comment. DATAROBOT_CLI_NON_INTERACTIVE is documented as the equivalent of --yes for the commands that read it (e.g. docs/commands/dependencies.md), so converting one into the other is faithful.

The export does reach further than the OpenCode installer, though: every nested dr process sees it, telemetry reports non_interactive=true, and internal/auth skips the URL picker and changes login output under it (auth.go:570, browserflow.go:328). Could the comment say the consent covers the whole nested chain, so the next reader doesn't assume it is scoped to the installer?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Close Jira on Merge go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants