fix(sl): classify semantic-query request rejections as expected, not faults (#339)

The daemon rejects an invalid semantic-query request (unknown source,
ambiguous measure, no join path) with a plain ValueError; the Node compute
port now maps the daemon's exit code 3 / HTTP 400 to KtxExpectedError so these
routine, caller-driven rejections stay out of Error Tracking.

A dedicated SemanticLayerRequestError(ValueError) is raised only for engine
rejections and routed through both daemon transports and the HTTP handler.
Because pydantic v2 ValidationError subclasses ValueError, malformed sources or
responses (contract faults) are kept as faults: they are reported and mapped to
exit 1 / HTTP 500 / plain Error on every path. Non-object stdin is likewise a
fault (exit 1), not exit 3.
This commit is contained in:
Andrey Avtomonov 2026-07-03 23:17:33 +02:00 committed by GitHub
parent 5d17469601
commit a0d19ba26f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View file

@ -424,6 +424,24 @@ def test_semantic_query_endpoint_maps_value_error_to_400() -> None:
assert "missing.order_count" in response.json()["detail"]
def test_semantic_query_endpoint_maps_malformed_source_to_fault() -> None:
client = TestClient(create_app(), raise_server_exceptions=False)
invalid_source = {
key: value for key, value in ORDERS_SOURCE.items() if key != "table"
}
response = client.post(
"/semantic-layer/query",
json={
"sources": [invalid_source],
"dialect": "postgres",
"query": {"measures": ["orders.order_count"], "dimensions": []},
},
)
assert response.status_code == 500
def test_semantic_validate_endpoint_returns_structured_validation() -> None:
client = TestClient(create_app())
invalid_source = {