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
7 changes: 5 additions & 2 deletions src/together/lib/cli/_track_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,12 @@ def format_cli_error_for_telemetry(exc: BaseException, *, command: str = "") ->
return sanitize_cli_error_message(msg)

if isinstance(exc, CycloptsError):
return sanitize_cli_error_message(_stringify_cyclopts_error(exc))
message = _stringify_cyclopts_error(exc)
else:
message = str(exc)

return sanitize_cli_error_message(str(exc))
sanitized = sanitize_cli_error_message(message)
return sanitized or type(exc).__name__


def _env_telemetry_disabled() -> bool:
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_cli_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ def test_format_cyclopts_error_omits_install_path() -> None:
assert err.verbose is True


def test_format_empty_cyclopts_error_uses_exception_type() -> None:
from cyclopts.exceptions import CycloptsError

assert format_cli_error_for_telemetry(CycloptsError()) == "CycloptsError"


@pytest.mark.parametrize("error", [RuntimeError(), RuntimeError(" \n")])
def test_format_empty_error_uses_exception_type(error: RuntimeError) -> None:
assert format_cli_error_for_telemetry(error) == "RuntimeError"


def test_telemetry_env_opt_out_only_explicit_values(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.delenv("TOGETHER_TELEMETRY_DISABLED", raising=False)
assert is_tracking_enabled() is True
Expand Down
Loading