Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(capture): document the session replay ingestion warnings (#77017)

Eli Reisman2ef206499975
diff --git a/.agents/skills/adding-ingestion-warnings/SKILL.md b/.agents/skills/adding-ingestion-warnings/SKILL.md
index af21dbff558e..0c25129b13ee 100644
--- a/.agents/skills/adding-ingestion-warnings/SKILL.md
+++ b/.agents/skills/adding-ingestion-warnings/SKILL.md
@@ -76,7 +76,9 @@ To add a **capture-produced** type:
1. **Register it in nodejs** — add the type to `INGESTION_WARNING_TYPES` with `captureProduced: true` (see the nodejs steps above for `category`/`severity`, which the consumer owns). This also puts it on the `CAPTURE_PRODUCED_WARNING_TYPES` allowlist automatically.
2. **Regenerate + commit the artifact** — run `pnpm --filter=@posthog/nodejs gen:ingestion-warning-types` and commit the updated `warning_types.generated.json`.
-3. **Add the Rust `from_tag` arm** — in `src/registry.rs`, map the capture error tag (`v1::Error::tag()` / per-event drop detail) to the newly generated `WarningType` variant. The variant, `as_str`, and `ALL` are generated — never hand-write them. `from_tag` stays hand-written because it maps capture's error taxonomy onto the registry and is the allowlist that makes unregistered tags emit nothing; the equality-weld test forces you to add the arm.
+3. **Put it on exactly one Rust emit route** in `src/registry.rs`. The variant, `as_str`, and `ALL` are generated — never hand-write them. The weld test forces you to pick a route and fails if you pick both.
+ - **`from_tag`** when a `v1::Error::tag()` (or per-event drop detail) already names the condition: add the arm mapping the tag to the variant. It stays hand-written because it maps capture's error taxonomy onto the registry and is the allowlist that makes unregistered tags emit nothing.
+ - **`DIRECT_EMIT`** when no tag names it, which is the case for most non-v1 pipelines. Two shapes qualify: the condition isn't a failure (a rate-limited event is ingested, degraded), or the pipeline has no tag vocabulary at all. The AI endpoints, the OTLP endpoint, and replay are all the second kind — they reject through their own typed conditions or match `CaptureError` variants directly, so a tag for them would be a string no `Error` ever produces.
### Team-aware Rust producers: the direct-row transport
@@ -94,7 +96,7 @@ Warning::new(WarningType::MyNewType)
Emitting from Rust:
- **Emit it** via `WarningEmitter::emit(token, source, warning, details, count)` — the builder injects `count` and `pipelineStep` into details and stamps `type`/`source`/`details` into the event properties the consumer reads. Use the same camelCase details keys as nodejs (`distinctId`, `eventUuid`, ...). The envelope's top-level `distinct_id` is always the token (never the offending id), so an oversized offending distinct_id can't make the consumer drop the warning.
-- **`source` identifies the producer** (`src/lib.rs`): a `WarningSource { service, path, pipeline_step }`. `service` is the stable message `source` field and metric label (e.g. `"capture"`) — pick one per service, don't invent a new value per call site. `path` is metric-only, for splitting volume within one service's emit sites (e.g. `"v1_analytics"`); it never reaches the message. `pipeline_step` is stamped into the envelope's details as `pipelineStep`. Capture declares one source per emit site: `CAPTURE_V1_ANALYTICS` and `CAPTURE_V1_RATE_LIMIT` (path `v1_analytics`), and `CAPTURE_LEGACY_ANALYTICS` and `CAPTURE_LEGACY_RATE_LIMIT` (path `legacy_analytics`) — see the constants in `src/lib.rs` for the current list.
+- **`source` identifies the producer** (`src/lib.rs`): a `WarningSource { service, path, pipeline_step }`. `service` is the stable message `source` field and metric label (e.g. `"capture"`) — pick one per service, don't invent a new value per call site. `path` is metric-only, for splitting volume within one service's emit sites (e.g. `"v1_analytics"`); it never reaches the message. `pipeline_step` is stamped into the envelope's details as `pipelineStep`. Capture declares one source per emit site: `CAPTURE_V1_ANALYTICS` and `CAPTURE_V1_RATE_LIMIT` (path `v1_analytics`), `CAPTURE_LEGACY_ANALYTICS` and `CAPTURE_LEGACY_RATE_LIMIT` (path `legacy_analytics`), `CAPTURE_AI_EVENTS` (path `ai_events`), `CAPTURE_AI_OTEL` (path `ai_otel`), and `CAPTURE_REPLAY` (path `replay`) — see the constants in `src/lib.rs` for the current list.
- **Best-effort, fire-and-forget**: throttled per `(token, type)` per pod, never awaited, never fails the caller. Capture gates it behind `CAPTURE_INGESTION_WARNINGS_ENABLED` (default off; see `rust/capture/src/config.rs`). The producer is a `common-kafka` `ThreadedProducer` (built via `create_threaded_kafka_producer_no_ping` with `observe_delivery` as its delivery callback, so delivered/failed outcomes are counted on the producer's own poll thread — no per-message task). It runs on its own dedicated `KafkaConfig` and its own destination: the emitter reads only `CAPTURE_INGESTION_WARNINGS_KAFKA_{HOSTS,TOPIC,TLS}` and never falls back to the main event cluster's `KAFKA_*` settings, so a deployment whose sink and warnings destination are different clusters (capture-ai produces events to WarpStream but warnings to MSK) is configurable. Empty hosts or topic means the emitter reports itself disabled rather than guessing. the fire-and-forget policy (`client.id=capture-ingestion-warnings`, `acks=1`, `retries=0`, `linger.ms=100`, a bounded 10k-message queue, a 5s message timeout) is fixed in code as the `WARNINGS_KAFKA_*` constants in `rust/capture/src/setup.rs` — not env-configurable — while only the two capacity/safety limits stay tunable via env (`CAPTURE_INGESTION_WARNINGS_KAFKA_QUEUE_MIB` and `..._MESSAGE_MAX_BYTES`). So a slow or saturated warnings topic can never contend with the main event producer.
- **Crate deps**: `common-ingestion-warnings` depends on `common-types` (for `CapturedEvent`) and `common-kafka` (the producer) — not on `capture` or any service crate. `WarningEmitter` is a plain trait object (`Arc<dyn WarningEmitter>`), so any Rust service can depend on the crate and wire it the way capture does in `router::State` / `setup.rs`; a team-aware service just supplies its own token.
diff --git a/frontend/src/scenes/data-management/ingestion-warnings/IngestionWarningsView.tsx b/frontend/src/scenes/data-management/ingestion-warnings/IngestionWarningsView.tsx
index 3048b2ca2be5..30ebbe655d08 100644
--- a/frontend/src/scenes/data-management/ingestion-warnings/IngestionWarningsView.tsx
+++ b/frontend/src/scenes/data-management/ingestion-warnings/IngestionWarningsView.tsx
@@ -59,6 +59,10 @@ export const WARNING_TYPE_TO_DESCRIPTION: Record<string, string> = {
invalid_ai_event: 'Discarded an AI event with an unsupported event name or no $ai_model',
invalid_ai_payload: 'Rejected a malformed AI or OpenTelemetry request',
no_ai_spans_ingested: 'Accepted an OpenTelemetry export with no AI spans, so nothing was ingested',
+ // Emitted by the capture service for its session replay endpoint
+ missing_session_id: 'Discarded a session replay batch with no $session_id',
+ invalid_session_id: 'Discarded a session replay batch with an invalid $session_id',
+ missing_snapshot_data: 'Discarded a session replay batch with no $snapshot_data',
}
// Explicit anchor on https://posthog.com/docs/data/ingestion-warnings for each warning type.
diff --git a/products/ingestion/skills/resolving-ingestion-warnings/SKILL.md b/products/ingestion/skills/resolving-ingestion-warnings/SKILL.md
index 65f9eda1dc5a..32152cce577b 100644
--- a/products/ingestion/skills/resolving-ingestion-warnings/SKILL.md
+++ b/products/ingestion/skills/resolving-ingestion-warnings/SKILL.md
@@ -72,7 +72,7 @@ Those decisions come only from this skill's guidance and your own reasoning.
### LLM analytics endpoints (`event`)
-Emitted by capture for its two dedicated AI endpoints, `/i/v0/ai` (a single event per request, sent multipart) and `/i/v0/ai/otel` (OTLP traces). These reject at the edge, so the events never reach the pipeline and appear nowhere else. Read the `path` detail to tell the endpoints apart: `ai_events` or `ai_otel`.
+Emitted by capture for its two dedicated AI endpoints, `/i/v0/ai` (a single event per request, sent multipart) and `/i/v0/ai/otel` (OTLP traces). These reject at the edge, so the events never reach the pipeline and appear nowhere else. Read the `path` detail to tell the endpoints apart: it carries the request path, so `/i/v0/ai` or `/i/v0/ai/otel`.
| Type | What happened | Fix |
| ---------------------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -102,8 +102,13 @@ Emitted by capture for its two dedicated AI endpoints, `/i/v0/ai` (a single even
### Session replay (`replay`)
-| Type | What happened | Fix |
-| ----------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `replay_lib_version_too_old` | Recording sent by an outdated posthog-js (1.x < 1.75) | Read [references/fixing-session-replay-warnings.md](references/fixing-session-replay-warnings.md) — recording still processed; upgrade posthog-js |
-| `message_contained_no_valid_rrweb_events` | A replay message carried no usable snapshot data | Read [references/fixing-session-replay-warnings.md](references/fixing-session-replay-warnings.md) — that recording chunk was dropped; usually a rewriting proxy/transport or old SDK |
-| `message_timestamp_diff_too_large` | Replay snapshot timestamps far from arrival time | Read [references/fixing-session-replay-warnings.md](references/fixing-session-replay-warnings.md) — chunk dropped at the 7-day threshold; persistent = clock skew, bursts = buffering |
+Two producers land in this category, and the `source` column tells them apart. `source = 'capture'` means capture rejected the request at the `/s` edge, so the batch reached nothing downstream and has no other trace; its `path` detail is `/s` or `/s/`. Anything else (`plugin-server`) came from the replay consumer, which had already accepted the batch. The first three rows below are the capture-stage ones.
+
+| Type | What happened | Fix |
+| ----------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `missing_session_id` | The batch's first `$snapshot` carried no `$session_id`, so the whole request was rejected | Read [references/fixing-capture-replay-rejections.md](references/fixing-capture-replay-rejections.md) — usually session-id management the SDK isn't driving |
+| `invalid_session_id` | `$session_id` was present but the wrong JSON type, over 70 chars, or outside `[A-Za-z0-9-]` | Read [references/fixing-capture-replay-rejections.md](references/fixing-capture-replay-rejections.md) — the `reason` detail names which rule broke; almost always a custom session id |
+| `missing_snapshot_data` | An event in the batch had no `$snapshot_data`, or it wasn't an array or object | Read [references/fixing-capture-replay-rejections.md](references/fixing-capture-replay-rejections.md) — the `reason` detail separates absent from wrong-type; check for a rewriting proxy |
+| `replay_lib_version_too_old` | Recording sent by an outdated posthog-js (1.x < 1.75) | Read [references/fixing-session-replay-warnings.md](references/fixing-session-replay-warnings.md) — recording still processed; upgrade posthog-js |
+| `message_contained_no_valid_rrweb_events` | A replay message carried no usable snapshot data | Read [references/fixing-session-replay-warnings.md](references/fixing-session-replay-warnings.md) — that recording chunk was dropped; usually a rewriting proxy/transport or old SDK |
+| `message_timestamp_diff_too_large` | Replay snapshot timestamps far from arrival time | Read [references/fixing-session-replay-warnings.md](references/fixing-session-replay-warnings.md) — chunk dropped at the 7-day threshold; persistent = clock skew, bursts = buffering |
diff --git a/products/ingestion/skills/resolving-ingestion-warnings/references/fixing-capture-replay-rejections.md b/products/ingestion/skills/resolving-ingestion-warnings/references/fixing-capture-replay-rejections.md
new file mode 100644
index 000000000000..bd8b39207518
--- /dev/null
+++ b/products/ingestion/skills/resolving-ingestion-warnings/references/fixing-capture-replay-rejections.md
@@ -0,0 +1,47 @@
+# Fixing capture replay rejections
+
+Covers `missing_session_id`, `invalid_session_id`, and `missing_snapshot_data`.
+
+These come from capture's session replay endpoint, `/s`, not from the replay consumer.
+They carry `source = 'capture'` and a `path` detail of `/s` or `/s/`, which is how you tell them apart from the other `replay`-category warnings, whose batches had already been accepted and which carry `source = 'plugin-server'`.
+
+Three things about this endpoint shape every diagnosis:
+
+- **It rejects at the edge.** The request got a `400` and nothing reached the pipeline, so the batch is not in `session_replay_events`, not in the recording list, and has no trace anywhere else. The warning is the only record.
+- **A batch is all-or-nothing.** Every `$snapshot` in one request is folded into a single `$snapshot_items` message, so one bad event rejects the whole request. `count` and `eventCount` are the number of events lost, which is why a single malformed event can show a `count` in the dozens.
+- **Metadata comes from the first event only.** `$session_id`, `distinct_id`, and the rest are read off `events[0]`. A batch mixing two sessions is filed under the first one's id without warning, so a batch that looks fine can still be misattributed.
+
+Check `lib` and `libVersion` first on every one of these. A rejection concentrated on one SDK version is an upgrade, not a payload problem. Replay has no SDK-info header, so `lib` may be derived from the user agent and read `web` when the payload carried no `$lib`.
+
+## `missing_session_id`
+
+The first `$snapshot` in the batch had no `$session_id` property at all.
+
+posthog-js and the mobile SDKs always set this, so seeing it means something other than a stock SDK is building the payload. In practice:
+
+- **Hand-rolled replay ingestion.** A script or server relay assembling `$snapshot` events itself, and omitting the property. `$session_id` is required; there is no default.
+- **Session management driven outside the SDK.** An integration that generates its own session ids and forgot to attach one to the replay payload, while analytics events still carry theirs.
+- **A rewriting proxy.** Something between the SDK and PostHog strips or renames properties. Compare a captured request body against what the browser actually sent.
+
+## `invalid_session_id`
+
+`$session_id` was present but unusable. The `reason` detail names which rule broke:
+
+- **`not_a_string`** — the value arrived as a number, boolean, object, or `null`. Usually a session id held as an integer and serialized without quoting. Send it as a JSON string.
+- **`too_long`** — over the 70-byte limit. `sessionIdLength` is the actual length. A UUID is 36 characters and fits comfortably, so this generally means a composite id (a session id concatenated with a user id, a tenant prefix, or a timestamp). Shorten it, or hash it to a UUID.
+- **`invalid_charset`** — the id contains something outside `[A-Za-z0-9-]`. Underscores, colons, slashes, dots, and spaces all land here, as does any non-ASCII character. Composite ids joined with `_` or `:` are the common case.
+
+The offending value itself is deliberately not in the details. It is unvalidated client input, and it would land in a customer-visible column, so `reason` and `sessionIdLength` carry the actionable part instead. To see the value, look at the SDK's own session id on the client.
+
+If you are generating session ids yourself, the safe format is a UUID. PostHog's own SDKs emit one.
+
+## `missing_snapshot_data`
+
+An event in the batch had no usable `$snapshot_data`. The `reason` detail separates the two cases:
+
+- **`absent`** — the property is missing entirely. Either an SDK too old to send it, or a payload assembled by hand. Note this can be a _later_ event in the batch: the first event can be perfectly valid and the request still rejects, which is why `count` covers events that looked fine.
+- **`wrong_json_type`** — the property is present but is neither an array of rrweb events nor a single event object. A string lands here, which is the signature of double-encoded JSON: the snapshot data was serialized to a string and then embedded, so it arrives as `"[{...}]"` rather than `[{...}]`. Also seen with `null` and with numbers.
+
+Double encoding is the most common cause worth ruling out first, and it points at whatever sits between the SDK and capture: a relay that re-serializes bodies, a proxy that treats the payload as an opaque string, or custom code doing an extra `JSON.stringify`.
+
+Note the neighbouring case that does **not** produce this warning: `$snapshot_data: []`, an empty array, is accepted by capture and rejected later by the replay consumer as `message_contained_no_valid_rrweb_events`. If a team reports missing recordings and you see that type instead, the problem is downstream of this endpoint.