Skip to content

Commit 749d3c7

Browse files
anandgupta42claude
andcommitted
fix: CI test failures and Sentry-flagged engine bootstrap crash
- Add duckdb to dev dependencies so CI installs it (fixes 19 test failures) - Add pytest skip markers for tests requiring sqlguard (proprietary Rust extension not available in CI) and boto3 (optional warehouse dependency) - Wrap ensureEngine() in try-catch in resolvePython() to show a clear error message instead of crashing the CLI on bootstrap failure (Sentry review) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fbdeb0c commit 749d3c7

6 files changed

Lines changed: 45 additions & 1 deletion

File tree

packages/altimate-code/src/bridge/client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ export namespace Bridge {
5858

5959
// 4. Production: uv-managed engine
6060
const { ensureEngine, enginePythonPath } = await import("./engine")
61-
await ensureEngine()
61+
try {
62+
await ensureEngine()
63+
} catch (err) {
64+
throw new Error(
65+
`Failed to bootstrap Python engine: ${err instanceof Error ? err.message : String(err)}. ` +
66+
`Set ALTIMATE_CLI_PYTHON to a Python 3.10+ interpreter to skip automatic bootstrap.`,
67+
)
68+
}
6269
return enginePythonPath()
6370
}
6471

packages/altimate-engine/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ tunneling = ["sshtunnel>=0.4", "paramiko>=3.0"]
5252
dev = [
5353
"pytest>=7.0",
5454
"ruff>=0.4",
55+
"duckdb>=0.9",
5556
]
5657

5758
[tool.hatch.build.targets.wheel]

packages/altimate-engine/tests/test_cost_gate.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88
from altimate_engine.ci.cost_gate import scan_files, _has_jinja, _split_statements
99

10+
try:
11+
import sqlguard
12+
_HAS_SQLGUARD = True
13+
except ImportError:
14+
_HAS_SQLGUARD = False
15+
16+
_needs_sqlguard = pytest.mark.skipif(not _HAS_SQLGUARD, reason="sqlguard not installed")
17+
1018

1119
# ---------------------------------------------------------------------------
1220
# Helpers
@@ -73,6 +81,7 @@ def test_clean_file_passes(self):
7381
finally:
7482
os.unlink(path)
7583

84+
@_needs_sqlguard
7685
def test_cartesian_product_has_warnings(self):
7786
"""CROSS JOIN produces lint warnings (SELECT *, missing aliases, no LIMIT)."""
7887
path = _write_temp_sql("SELECT * FROM a CROSS JOIN b")
@@ -133,6 +142,7 @@ def test_multiple_files_mixed(self):
133142
os.unlink(clean_path)
134143
os.unlink(warn_path)
135144

145+
@_needs_sqlguard
136146
def test_multiple_statements_in_file(self):
137147
"""Multiple statements: lint runs on each; warnings don't fail the gate."""
138148
path = _write_temp_sql("SELECT 1; SELECT * FROM a CROSS JOIN b;")

packages/altimate-engine/tests/test_enterprise_connectors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
from altimate_engine.connections import ConnectionRegistry
88

9+
try:
10+
import boto3
11+
_HAS_BOTO3 = True
12+
except ImportError:
13+
_HAS_BOTO3 = False
14+
915

1016
@pytest.fixture(autouse=True)
1117
def reset_registry():
@@ -37,6 +43,7 @@ def test_inherits_postgres(self):
3743

3844
assert issubclass(RedshiftConnector, PostgresConnector)
3945

46+
@pytest.mark.skipif(not _HAS_BOTO3, reason="boto3 not installed")
4047
def test_iam_role_requires_cluster_id(self):
4148
from altimate_engine.connectors.redshift import RedshiftConnector
4249

packages/altimate-engine/tests/test_feedback_store.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88
from altimate_engine.sql.feedback_store import FeedbackStore, _regex_strip_literals
99

10+
try:
11+
import sqlguard
12+
_HAS_SQLGUARD = True
13+
except ImportError:
14+
_HAS_SQLGUARD = False
15+
16+
_needs_sqlguard = pytest.mark.skipif(not _HAS_SQLGUARD, reason="sqlguard not installed")
17+
1018

1119
@pytest.fixture
1220
def store(tmp_path):
@@ -325,6 +333,7 @@ def test_tier4_with_window_functions(self, store):
325333
windowed = store.predict("SELECT id, ROW_NUMBER() OVER (ORDER BY id) FROM t")
326334
assert windowed["predicted_bytes"] >= base["predicted_bytes"]
327335

336+
@_needs_sqlguard
328337
def test_tier4_cross_join_high_complexity(self, store):
329338
"""CROSS JOINs should significantly increase the estimate."""
330339
simple = store.predict("SELECT id FROM t")

packages/altimate-engine/tests/test_server.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
from altimate_engine.server import dispatch, handle_line
66
from altimate_engine.models import JsonRpcRequest
77

8+
try:
9+
import sqlguard
10+
_HAS_SQLGUARD = True
11+
except ImportError:
12+
_HAS_SQLGUARD = False
13+
14+
_needs_sqlguard = pytest.mark.skipif(not _HAS_SQLGUARD, reason="sqlguard not installed")
15+
816

917
class TestDispatch:
1018
def test_ping(self):
@@ -14,6 +22,7 @@ def test_ping(self):
1422
assert "version" in response.result
1523
assert response.error is None
1624

25+
@_needs_sqlguard
1726
def test_sql_analyze(self):
1827
request = JsonRpcRequest(
1928
method="sql.analyze",
@@ -83,6 +92,7 @@ def test_warehouse_list(self):
8392
assert response.error is None
8493
assert "warehouses" in response.result
8594

95+
@_needs_sqlguard
8696
def test_sql_format(self):
8797
request = JsonRpcRequest(
8898
method="sql.format",

0 commit comments

Comments
 (0)