Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(clis): prevent background probes from opening login pages

rubenluetke10-beepd940a40d1302
diff --git a/jarvis/clis/prober.py b/jarvis/clis/prober.py
index 1f349b6640..9e406b657d 100644
--- a/jarvis/clis/prober.py
+++ b/jarvis/clis/prober.py
@@ -16,9 +16,10 @@ from __future__ import annotations
import asyncio
import json
import logging
+import os
import re
import shutil
-from asyncio.subprocess import PIPE
+from asyncio.subprocess import DEVNULL, PIPE
from typing import Literal
from jarvis.clis.spec import CliSpec, CliStatus, StatusParseStrategy
@@ -156,8 +157,10 @@ class CliStatusProber:
try:
proc = await asyncio.create_subprocess_exec(
*check_argv,
+ stdin=DEVNULL,
stdout=PIPE,
stderr=PIPE,
+ env={**os.environ, "CI": "true"},
creationflags=NO_WINDOW_CREATIONFLAGS,
)
try:
@@ -199,10 +202,15 @@ class CliStatusProber:
*spec.auth.status_command[1:],
)
try:
+ # Status checks must never start an interactive login. In particular,
+ # Neon opens a browser from `me` when credentials are missing unless
+ # CI is set. Keep this child-local so explicit OAuth login still works.
proc = await asyncio.create_subprocess_exec(
*status_argv,
+ stdin=DEVNULL,
stdout=PIPE,
stderr=PIPE,
+ env={**os.environ, "CI": "true"},
creationflags=NO_WINDOW_CREATIONFLAGS,
)
try:
diff --git a/tests/unit/clis/test_prober_noninteractive.py b/tests/unit/clis/test_prober_noninteractive.py
new file mode 100644
index 0000000000..40bcdd5d1c
--- /dev/null
+++ b/tests/unit/clis/test_prober_noninteractive.py
@@ -0,0 +1,68 @@
+"""Background probes must not initiate browser authentication."""
+
+from __future__ import annotations
+
+import os
+import sys
+from dataclasses import replace
+from pathlib import Path
+
+import pytest
+
+from jarvis.clis.catalog import CliCatalog
+from jarvis.clis.prober import CliStatusProber
+
+
[email protected]("parent_ci", [None, "false"])
[email protected]("credentials", ["missing", "expired", "valid"])
+async def test_repeated_probes_do_not_launch_login(
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+ parent_ci: str | None,
+ credentials: str,
+) -> None:
+ """Exercise real child environments with a CLI simulating Neon's auth fallback."""
+ if parent_ci is None:
+ monkeypatch.delenv("CI", raising=False)
+ else:
+ monkeypatch.setenv("CI", parent_ci)
+ monkeypatch.setenv("PROBE_TEST_CREDENTIALS", credentials)
+ browser_marker = tmp_path / "browser-opened"
+ cli = tmp_path / "cli.py"
+ cli.write_text(
+ "import os, sys\n"
+ "from pathlib import Path\n"
+ "if os.environ.get('CI') != 'true':\n"
+ " Path(sys.argv[1]).touch()\n"
+ " sys.exit(1)\n"
+ "if sys.stdin.read() != '':\n"
+ " sys.exit(2)\n"
+ "if sys.argv[2] == '--version':\n"
+ " print('1.2.3')\n"
+ "elif os.environ['PROBE_TEST_CREDENTIALS'] == 'valid':\n"
+ " print('{\"id\": \"test-user\"}')\n"
+ "else:\n"
+ " print('Cannot run interactive auth in CI', file=sys.stderr)\n"
+ " sys.exit(1)\n",
+ encoding="utf-8",
+ )
+ neon = CliCatalog(custom_path=tmp_path / "custom.json").get("neonctl")
+ assert neon is not None
+ command = (sys.executable, str(cli), str(browser_marker))
+ spec = replace(
+ neon,
+ binary_name=sys.executable,
+ check_command=(*command, "--version"),
+ auth=replace(neon.auth, status_command=(*command, "me")),
+ )
+ for _ in range(2):
+ status = await CliStatusProber().probe(spec)
+ assert status.installed
+ assert status.version == "1.2.3"
+ assert status.auth_status == (
+ "connected" if credentials == "valid" else "not_connected"
+ )
+ assert not browser_marker.exists()
+ # An explicit login in the parent must retain its interactive environment.
+ assert os.environ.get("CI") == parent_ci