Skip to content

Conversation

@peaBerberian
Copy link
Collaborator

This is a backport of #1713 for an upcoming v3.33.6

@peaBerberian peaBerberian added this to the 3.33.6 milestone Aug 11, 2025
@peaBerberian peaBerberian force-pushed the fix/persistent-no-key-id-v3 branch 2 times, most recently from f931107 to be24abb Compare August 11, 2025 15:32
We saw issues with some contents from a partner using persistent
licenses.

After investigations, I noticed that the stored metadata linked to
persisted licences could be corrupted if, and only if, key ids are not
known in advance through the Manifest nor through segments.

Thankfully this is a very rare occurence, itself happening also only in
the rare scenario where persisted sessions are used - but we did actually
saw it with content from a partner (italian one).

---

The root cause was due to a simple JS gotcha: the result of an Array's
`every` method (which returns `true` if all elements from an array
follow the given predicate) when the array it is applied to is empty.

Turns out it returns `true` (it even kind of makes sense when you think
hard about it :p!).

Yet we were using it in the following type of condition:
```js
if (currentKeyIds !== undefined) {
  const isCurrentPersistentLicenseCompatible = currentKeyIds.every(keyId => {
    return storedEntry.keyIds.includes(keyId);
  });
}
```

So here, if `currentKeyIds` is defined but empty, it would return `true`
for any `storedEntry`, even ones linked to a license that do not apply
to the current content.

Note that we have a valid fallback in cases where keyIds are unknown,
which is to check whole PSSH instead.
Here we should go through this strategy instead - but we didn't consider
the "empty keyIds array" as equivalent to "no known key id". Now we do.

Also a more efficient solution could also be to tell those partners to just
advertise their key id like everybody else - which also leads to more
performance-linked tricks elsewhere. Though we already tried with
no success.
@peaBerberian peaBerberian force-pushed the fix/persistent-no-key-id-v3 branch from be24abb to 0f49e5b Compare August 11, 2025 15:34
@peaBerberian peaBerberian merged commit 48a8b35 into legacy-v3 Aug 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants