Repository navigation
[AECO-2370] feat(build-studio): export --yes as DATAROBOT_CLI_NON_INTERACTIVE for nested processes - #1104
[AECO-2370] feat(build-studio): export --yes as DATAROBOT_CLI_NON_INTERACTIVE for nested processes#1104Anton Bogatyrov (antonbogatyrov) wants to merge 2 commits into
Conversation
… 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>
|
🎫 AECO-2370 · Bug
|
… 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>
AJ Alon (ajalon1)
left a comment
There was a problem hiding this comment.
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.Setenvto make this happen, since this also mutates thedrprocess 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. ReadingbuildPluginEnvconfirms it does (os.Environ()), so I'm not asking for more.
| if err := os.Setenv(reader.NonInteractiveEnv, "1"); err != nil { | ||
| log.Debug("Failed to export non-interactive consent", "error", err) | ||
| } |
There was a problem hiding this comment.
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.
| 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.
| // 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. |
There was a problem hiding this comment.
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?
RATIONALE
Part of AECO-2370 (
dr build-studio --yeshangs on "Starting OpenCode server…" when OpenCode is not installed).dr build-studioinstalls the xp and opencode plugins, but the OpenCode application is installed lazily by the opencode wrapper on its first run — which happens insidedr opencode serve, a grandchild process dr xp spawns headless when the Assist tab opens. The user's--yesnever 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--yesas the CLI's standard automation switch.CHANGES
runStudio: when consent was given (-y/--yes, orDATAROBOT_CLI_NON_INTERACTIVEalready set by the user), setDATAROBOT_CLI_NON_INTERACTIVE=1before launching xp. Nested processes inherit it; the opencode wrapper (datarobot/opencode-cli-plugin#76) installs OpenCode without prompting only when it is set.--yesnothing 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).--yesand stays unset without it.RELATED
PR 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)🤖 Generated with Claude Code