b466a6fc8c
Staging PostgREST rejects the executiveSummary JSON-path alias, so GET /api/reports 500s. Persist a plain card_summary column from the Markdown excerpt instead. Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
828 B
TypeScript
22 lines
828 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { sanitizedErrorReason } from "../src/lib/safe-error-reason.ts";
|
|
|
|
test("sanitizedErrorReason reads PostgREST code/hint from non-Error objects", () => {
|
|
assert.equal(sanitizedErrorReason("boom"), "UnknownError");
|
|
assert.equal(sanitizedErrorReason(new Error("secret row")), "Error");
|
|
assert.equal(
|
|
sanitizedErrorReason({ code: "42703", hint: "column does not exist" }),
|
|
"UnknownError code=42703 hint=column does not exist",
|
|
);
|
|
assert.equal(
|
|
sanitizedErrorReason({ name: "PostgrestError", code: "PGRST204", hint: "" }),
|
|
"PostgrestError code=PGRST204 hint=none",
|
|
);
|
|
assert.doesNotMatch(
|
|
sanitizedErrorReason({ code: "42703", message: "row body must not be logged", details: "secret" }),
|
|
/row body|secret/,
|
|
);
|
|
});
|