From 2815bc0ee0c55f2a3c41294e013a710a173c45b1 Mon Sep 17 00:00:00 2001 From: Chandan Kumar Date: Mon, 2 Nov 2026 21:38:23 -0500 Subject: [PATCH] Show the real Databricks CLI error, not the version notice that precedes it Co-Authored-By: Claude Sonnet 5.5 --- labagent/packs/base.py | 2 +- labagent/packs/databricks/cli.py | 5 ++++- tests/test_packs.py | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/labagent/packs/base.py b/labagent/packs/base.py index b321e69..649c84f 100644 --- a/labagent/packs/base.py +++ b/labagent/packs/base.py @@ -152,7 +152,7 @@ def run_pack(pack: Pack, action: str, name: str, given: Dict[str, Any], services save_state(pack.id, name, ctx.state) item["state"] = "done" except PackError as e: - item.update(state="failed", error=str(e)[:400]) + item.update(state="failed", error=str(e)[:600]) break except Exception as e: # unexpected: class name only, never the message (could carry a token) item.update(state="failed", error=type(e).__name__) diff --git a/labagent/packs/databricks/cli.py b/labagent/packs/databricks/cli.py index 8c88c09..fd4a90a 100644 --- a/labagent/packs/databricks/cli.py +++ b/labagent/packs/databricks/cli.py @@ -14,7 +14,10 @@ def redact(text: str, tail: int = 8) -> str: - return SECRET.sub("", "\n".join(text.strip().splitlines()[-tail:]))[:1200] + lines = text.strip().splitlines() + # a newer CLI prints a "Your current $PATH prefers running CLI v0.x ..." notice before the real error: start at the error + start = next((i for i, l in enumerate(lines) if l.startswith("Error")), 0) + return SECRET.sub("", "\n".join(lines[start:][:tail] if start else lines[-tail:]))[:1200] class Dbx: diff --git a/tests/test_packs.py b/tests/test_packs.py index bf877cf..911bf9d 100644 --- a/tests/test_packs.py +++ b/tests/test_packs.py @@ -159,3 +159,12 @@ def test_packs_json_never_contains_a_credential(capsys, home, monkeypatch): monkeypatch.setenv("GROQ_API_KEY", "gsk_" + "a" * 40) main(["packs", "--json"]) assert "gsk_" not in capsys.readouterr().out + + +def test_cli_error_skips_the_version_notice(): + from labagent.packs.databricks.cli import redact + text = ("Your current $PATH prefers running CLI v0.18.0 at /x/databricks\n\nBecause both are installed...\n" + "Executing CLI v1.23.0...\n------------------------\nError: Failed to create app: limit of 3 apps reached") + out = redact(text) + assert out.startswith("Error: Failed to create app: limit of 3 apps reached") + assert "prefers" not in out