Release/4.10.2 - #1504
Merged
Merged
Release/4.10.2#1504
Conversation
… 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.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fixes: