FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: SDK errors exit cleanly from the migration CLI · inputlayer/inputlayer@862fe72 · GitHub

Commit 862fe72

Browse files
committed
fix: SDK errors exit cleanly from the migration CLI
Found by live demo verification: an unreachable server printed a raw InputLayerConnectionError traceback. The CLI now catches InputLayerError alongside MigrationError and prints a one-line error with exit 1. Test added; suite 970 passed.
1 parent 4c6025d commit 862fe72

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎packages/inputlayer-py/src/inputlayer/migrations/cli.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def build_parser() -> argparse.ArgumentParser:
267267

268268
def main(argv: list[str] | None = None) -> int:
269269
"""CLI entry point."""
270+
from inputlayer.exceptions import InputLayerError
270271
from inputlayer.migrations.errors import MigrationError
271272

272273
parser = build_parser()
@@ -278,7 +279,7 @@ def main(argv: list[str] | None = None) -> int:
278279

279280
try:
280281
return args.func(args)
281-
except MigrationError as exc:
282+
except (MigrationError, InputLayerError) as exc:
282283
print(f"error: {exc}")
283284
return 1
284285

‎packages/inputlayer-py/tests/test_cli.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ def test_build_parser(self):
1818
def test_no_command_returns_1(self):
1919
assert main([]) == 1
2020

21+
def test_connection_error_prints_cleanly(self, capsys, monkeypatch):
22+
# SDK errors (unreachable server, auth failure) must exit 1 with a
23+
# clean message, not a traceback.
24+
from inputlayer.exceptions import InputLayerConnectionError
25+
from inputlayer.migrations import cli
26+
27+
def boom(args):
28+
raise InputLayerConnectionError("Failed to connect to ws://nope")
29+
30+
monkeypatch.setattr(cli, "_cmd_showmigrations", boom)
31+
rc = main(["showmigrations", "--url", "ws://nope", "--kg", "k"])
32+
assert rc == 1
33+
out = capsys.readouterr().out
34+
assert "error: Failed to connect" in out
35+
2136
def test_makemigrations_requires_models(self):
2237
parser = build_parser()
2338
with pytest.raises(SystemExit):

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL