Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion labagent/packs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
5 changes: 4 additions & 1 deletion labagent/packs/databricks/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@


def redact(text: str, tail: int = 8) -> str:
return SECRET.sub("<redacted>", "\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("<redacted>", "\n".join(lines[start:][:tail] if start else lines[-tail:]))[:1200]


class Dbx:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_packs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading