Skip to content

Release/4.10.2 - #1504

Merged
Matus Tomlein (matus-tomlein) merged 1 commit into
masterfrom
release/4.10.2
Sep 9, 2026
Merged

Matus Tomlein (matus-tomlein) merged 1 commit into
masterfrom
release/4.10.2

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

… source is attached (#1503)

## Problem

The `org.whatwg/media_element` schema requires `currentSrc` and
constrains it to `format: uri`, which an **empty string does not
satisfy**. Both `currentSrc` and `src` return empty while no source is
attached (`networkState` = `NETWORK_EMPTY`), so the entity emitted in
that window is rejected as a schema violation and the whole event is
dropped as a bad row.

The window matters more than it first appears:

1. **Media Source Extensions (MSE) players never set a `src`
attribute.** [MSE](https://www.w3.org/TR/media-source-2/) is the browser
API behind all adaptive streaming (HLS/DASH): JavaScript fetches the
media itself and feeds bytes to the element, rather than the browser
loading a file from a URL. The player creates a `MediaSource`, assigns
it via `URL.createObjectURL()` — which yields a `blob:` URL — and
attaches it. Between element creation and that attachment, both
`currentSrc` and `src` are `''`. This affects hls.js, dash.js, Shaka
Player and Video.js; a plain `<video src="movie.mp4">` is never
affected.
2. **Tracking commonly starts inside that window** —
`startMediaTracking` is called synchronously in `setUpListeners`.
3. **Ping events fire on a wall-clock timer** from that point regardless
of `readyState`, so the invalid entity recurs for the entire
pre-attachment window rather than once.

Reported by a customer running js-4.6.6 with ~17.5k `schema_violations`
bad rows over 7 days, during a limited test-phase rollout.

### `blob:` URLs were never affected

The original report also claimed `blob:` URLs fail validation. They
don't, and no change is needed for them. Verified two ways:

- Enrich validates via `com.networknt:json-schema-validator` (pinned
1.5.8 through iglu-scala-client 4.2.1). Its `format: uri` is `UriFormat`
→ `new java.net.URI(value)` → `uri.isAbsolute()`. `blob:https://…`
parses as scheme `blob` with an opaque scheme-specific part, so
`isAbsolute()` is `true` → **passes**. An empty string parses but has no
scheme → **fails**.
- The customer's own successfully-tracked events contain
`blob:https://…` values.

Worth noting for future schema work: `format` is a **hard assertion**
here, not an annotation — Iglu leaves `formatAssertionsEnabled` unset
and the library defaults it to `true` for dialects below draft 2019-09.

## Fix

Omit the entity while there is no source to describe, rather than
emitting one the pipeline rejects.

- **`entities.ts`** — `buildHTMLMediaElementEntity` now returns
`SelfDescribingJson | null`, returning `null` when neither `currentSrc`
nor `src` has a value. `currentSrc`, `src`, and `fileExtension` all
derive from two locals so no field can serialize as `''`.
- **`helperFunctions.ts`** — the data-URI placeholder is now `'data:'`
instead of `'DATA_URL'`. That sentinel was a **second, independent**
violation of the same `format: uri` constraint: a bare string with no
scheme fails for the same reason an empty string does. It has no timing
component, so it would have kept producing bad rows even after the
empty-string fix.
- **`player.ts`** — `htmlContext` widened to the nullable callback type.

This needs no changes to the context plumbing: `DynamicContext`
callbacks are already typed to return `SelfDescribingJson | null`, and
`resolveDynamicContext` ends with `.filter(Boolean)`. Returning `null`
drops only that entity — the media event and every other entity are
unaffected.

Because the context is resolved **per event**, this also handles the
mid-session cases a caller-side timing workaround cannot: a source swap,
`load()`, or playlist advance that returns the element to
`NETWORK_EMPTY` re-omits the entity, and it reappears automatically once
a source reattaches.
@snowplowcla Snowplow CLA bot (snowplowcla) added the cla:no [Auto generated] Snowplow Contributor License Agreement has not been signed. label Sep 9, 2026
@snowplowcla

Copy link
Copy Markdown

Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://docs.snowplowanalytics.com/docs/contributing/contributor-license-agreement/ to learn more and sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

@matus-tomlein
Matus Tomlein (matus-tomlein) merged commit c205629 into master Sep 9, 2026
7 checks passed
@matus-tomlein
Matus Tomlein (matus-tomlein) deleted the release/4.10.2 branch September 9, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:no [Auto generated] Snowplow Contributor License Agreement has not been signed.

Development

Successfully merging this pull request may close these issues.

2 participants