ingest-api: allow unknown event JSON fields for forward-compatible clients

- Relax Fastify/AJV schema on ingest events (additionalProperties: true)
  so CRM/deploy smokes sending extra keys no longer fail validation with 400.
- Add integration test when ERROR_REPORTING_TEST_DATABASE_URL is set.
- Document BIT-SMOKE / BIT-931 triage in RUNBOOK_INGEST_DEBUG; note in
  ingest-hardening-runbook.

Paperclip-Agent: 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376
Paperclip-Issue: 35542fda-44d4-4154-b95d-1a7de3566204
Paperclip-Run: 3682ff13-02fc-4749-a460-6414830dccc7
Made-with: Cursor
This commit is contained in:
Peter Spark committed 2026-04-05 04:33:08 +00:00
1 parent d7f9642606
commit d47a061399
4 files changed
+57 -1

No files matched your search

@@ -132,6 +132,33 @@ describe.skipIf(!_testUrl)("two-project passive ingest (BIT-179)", () => {
expect(Number((checkB[0] as { c: number }).c)).toBe(1);
});
it("accepts unknown event-level fields (forward-compatible for CRM / deploy smokes)", async () => {
const _res = await _app.inject({
method: "POST",
url: "/v1/ingest/events",
headers: { authorization: `Bearer ${_tokenA}` },
payload: {
events: [
{
schema_version: 1,
occurred_at: "2026-03-22T10:05:00.000Z",
level: "error",
message: "probe with extra keys",
fingerprint: "fp-extra-keys-1",
release: "1.0.0",
environment: "production",
},
],
},
});
expect(_res.statusCode).toBe(200);
const _body = JSON.parse(_res.body) as {
results: Array<{ incident_id: string; fingerprint: string }>;
};
expect(_body.results).toHaveLength(1);
expect(_body.results[0]?.fingerprint).toBe("fp-extra-keys-1");
});
it("skips known browser noise without inserting rows", async () => {
const [before] = await _pool.execute<RowDataPacket[]>(
`SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`,