Files
SnapOtter/packages/ai/python/test_sidecar_errors.py
T
SnapOtterandGitHub 04ef1141fb feat(telemetry): readable Sentry errors, Python tracebacks, and diagnostic mode
Keeps a real, redacted error message instead of "Error: Error", surfaces Python tracebacks in Sentry as a vetted context, and adds an opt-in SNAPOTTER_SENTRY_DIAGNOSTIC verbose mode plus SNAPOTTER_SENTRY_DSN_OVERRIDE. The default fleet path ships nothing on the never-collect list; raw detail is reachable only via the opt-in flag. Also classifies Redis OOM/READONLY replies as operational and removes a ReDoS in stack-frame extraction.
2026-08-03 13:13:38 +08:00

32 lines
1.0 KiB
Python

import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from sidecar_errors import build_error_envelope, redact # noqa: E402
def test_redact_masks_paths_and_files():
assert redact("open /data/uploads/9f/in.bin") == "open <path>"
assert redact("cannot read family_photo.JPG") == "cannot read <file>"
assert redact("torch 2.2.0 ok") == "torch 2.2.0 ok"
def test_envelope_shape_and_frames():
try:
raise RuntimeError("CUDA out of memory for /data/x.png")
except RuntimeError as exc:
env = build_error_envelope(exc)
assert env["type"] == "RuntimeError"
assert env["message"] == "CUDA out of memory for <path>"
assert isinstance(env["frames"], list) and len(env["frames"]) >= 1
top = env["frames"][-1]
assert top["file"] == "test_sidecar_errors.py"
assert isinstance(top["line"], int)
assert top["func"] == "test_envelope_shape_and_frames"
if __name__ == "__main__":
test_redact_masks_paths_and_files()
test_envelope_shape_and_frames()
print("ok")