mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
32 lines
1.0 KiB
Python
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")
|