The Fastify JSON Schema for POST /v1/ingest/events used additionalProperties:false on the root object. CRM direct-forward smokes that attach batch metadata beside events were rejected with HTTP 400 before the handler. - ingestJsonSchemas.ts: shared event and batch schemas - ingestJsonSchemas.test.ts: Ajv regression without MySQL - integration.twoProjects.test.ts: end-to-end case when DB URL set - docs/RUNBOOK_INGEST_DEBUG.md: document batch-level forwards Paperclip-Agent: 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376 Paperclip-Issue: BIT-933 Paperclip-Run: f027c017-4cbf-4819-84bb-85922e5c0407 Made-with: Cursor
31 lines
823 B
TypeScript
31 lines
823 B
TypeScript
import { Ajv } from "ajv";
|
|
import { describe, expect, it } from "vitest";
|
|
import { ingestBatchBodyJsonSchema } from "./ingestJsonSchemas.js";
|
|
|
|
describe("ingestBatchBodyJsonSchema", () => {
|
|
const _ajv = new Ajv({ strict: false, allErrors: true });
|
|
const _validate = _ajv.compile(ingestBatchBodyJsonSchema);
|
|
|
|
it("allows unknown top-level properties (CRM direct-forward metadata)", () => {
|
|
const _ok = _validate({
|
|
events: [
|
|
{
|
|
schema_version: 1,
|
|
occurred_at: "2026-03-22T10:00:00.000Z",
|
|
level: "error",
|
|
message: "x",
|
|
},
|
|
],
|
|
forward_source: "crm_smoke",
|
|
});
|
|
expect(_ok).toBe(true);
|
|
});
|
|
|
|
it("still requires events", () => {
|
|
const _ok = _validate({
|
|
forward_source: "crm_smoke",
|
|
});
|
|
expect(_ok).toBe(false);
|
|
});
|
|
});
|