Skip to content

Commit e141d7a

Browse files
paddymulclaude
andcommitted
fix(server): gate xorq infinite_request error_info on BUCKAROO_DEBUG
Closes #798. ``handle_infinite_request_xorq`` was returning ``traceback.format_exc()`` in the response's ``error_info`` field unconditionally, leaking server-side source paths and stack frames to WS clients in any production deployment. This patch mirrors the pandas WS-handler pattern at ``websocket_handler.py:241-245``: log the full traceback server-side (at ERROR level), but ship a generic ``"Request failed"`` to the client unless ``BUCKAROO_DEBUG=1`` is set. Pre-fix, the operator running a non-debug server *also* had no record of the error (the xorq handler didn't log). This patch fixes that gap too — same ``log.error`` shape as the pandas path. Test from the previous commit now passes; full ``test_load_expr.py`` suite green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1da4ee3 commit e141d7a

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

buckaroo/server/xorq_loading.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
"""
99
from __future__ import annotations
1010

11+
import logging
12+
import os
1113
import traceback
1214

1315
from buckaroo.xorq_buckaroo import (
1416
NoCleaningConfXorq, XorqAutocleaning, XorqDataflow, XorqDfStatsV2,
1517
XorqInfiniteSampling, _XORQ_ANALYSIS_KLASSES, _expr_count,
1618
window_to_parquet)
1719

20+
# Mirrors ``websocket_handler._BUCKAROO_DEBUG`` — when set, error_info
21+
# carries the full traceback for local debugging. Without it, clients see
22+
# a generic message so source paths and stack frames don't leak.
23+
_BUCKAROO_DEBUG = os.environ.get("BUCKAROO_DEBUG", "").lower() in ("1", "true")
24+
log = logging.getLogger("buckaroo.server.xorq_loading")
25+
1826

1927
class XorqServerDataflow(XorqDataflow):
2028
"""Headless XorqDataflow with infinite sampling.
@@ -87,5 +95,11 @@ def handle_infinite_request_xorq(xorq_dataflow: XorqServerDataflow,
8795
return ({"type": "infinite_resp", "key": payload_args, "data": [],
8896
"length": total_length}, parquet_bytes)
8997
except Exception:
98+
tb = traceback.format_exc()
99+
log.error("xorq infinite_request error: %s", tb)
100+
# Mirrors the pandas-path gate in websocket_handler.py — clients
101+
# in production runs see a generic message; only ``BUCKAROO_DEBUG``
102+
# opens the source-leak channel.
90103
return ({"type": "infinite_resp", "key": payload_args, "data": [],
91-
"length": 0, "error_info": traceback.format_exc()}, b"")
104+
"length": 0,
105+
"error_info": tb if _BUCKAROO_DEBUG else "Request failed"}, b"")

0 commit comments

Comments
 (0)