feat(telemetry): add a safe input_format tag to worker error reports (#541)

Every worker tool error now carries an input_format tag (file extension only, never the filename) for triage, derived once at the worker error path and added to the scrubber allowlist.
This commit is contained in:
SnapOtter
2026-07-16 19:27:16 +08:00
committed by GitHub
parent 631d82eaae
commit 281b4a06e3
5 changed files with 33 additions and 2 deletions
+14
View File
@@ -4,9 +4,23 @@ import {
classifyError,
errorSignature,
resetThrottleForTests,
safeFormatTag,
shouldReport,
} from "../../../apps/api/src/lib/error-report.js";
describe("safeFormatTag", () => {
it("returns the lowercase extension as a safe, non-PII tag", () => {
expect(safeFormatTag("photo.JPEG")).toBe("jpeg");
expect(safeFormatTag("doc.pdf")).toBe("pdf");
expect(safeFormatTag("clip.final.mp4")).toBe("mp4");
});
it("returns undefined when there is no plausible extension", () => {
expect(safeFormatTag(undefined)).toBeUndefined();
expect(safeFormatTag("noext")).toBeUndefined();
expect(safeFormatTag("weird.name-with-dashes")).toBeUndefined();
});
});
describe("classifyError", () => {
it("expected: tool input, aborts, worker cancel/timeout strings, zod, upload validation", () => {
expect(classifyError(new ToolInputError("bad csv"))).toBe("expected");
+2 -1
View File
@@ -14,7 +14,7 @@ const evt = (over: AnyEvent = {}): AnyEvent => ({
runtime: { name: "node", version: "22.1.0" },
device: { hostname: "leak" },
},
tags: { tool_id: "resize", secret_tag: "leak" },
tags: { tool_id: "resize", input_format: "webp", secret_tag: "leak" },
exception: {
values: [
{
@@ -99,6 +99,7 @@ describe("buildBeforeSend (api)", () => {
runtime: { name: "node", version: "22.1.0" },
});
expect(out.tags.tool_id).toBe("resize");
expect(out.tags.input_format).toBe("webp");
expect(out.tags.secret_tag).toBeUndefined();
});
it("drops contexts entirely when nothing allowlisted survives", () => {