ingest-api: allow unknown top-level keys on ingest batch (BIT-933)

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
This commit is contained in:
Peter Spark committed 2026-04-05 04:35:50 +00:00
1 parent d47a061399
commit 1c65ed3158
7 files changed
+101 -33

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@
2. **URL:** must be the ingest service base (no path suffix in env) — clients append `/v1/ingest/events` themselves (see [clients/php/ErrorReporter.php](../clients/php/ErrorReporter.php), [HTTP_CONTRACTS.md](HTTP_CONTRACTS.md)).
3. **Credentials:** `Authorization: Bearer <token>` or `X-Api-Key`; key must be **active** and **unexpired** in `er_ingest_keys` (§2).
4. **HTTP codes:** `401` / `429` / `5xx` / timeouts — use sections below; CRM cURL timeouts are short (e.g. 4s) — slow proxies can fail smokes before the hub responds.
5. **HTTP 400 from schema validation** should be rare; the hub ignores unknown **event-level** JSON keys and only requires `schema_version`, `occurred_at`, `level`, `message`.
5. **HTTP 400 from schema validation** should be rare; the hub ignores unknown **event-level** JSON keys and unknown **top-level** keys on the batch object (only `events` is required). Required per event: `schema_version`, `occurred_at`, `level`, `message`.
**After the root cause is fixed**