A stream media part whose base64 does not decode is a row with no Open, and the stream's other rows keep theirs #203

Merged
agra merged 1 commit from task/3730-a-stream-media-part-with-malformed-base6 into master 2026-10-31 09:28:58 +02:00
Owner

Tracker: #3730

blobOf (web/src/lib/media.ts) decoded a base64 data URL with atob, which throws InvalidCharacterError on malformed base64. The throw escaped the file row's effect while the stream rendered, so a valid document drawn in the same pass lost its Open, and the console held the error.

blobOf now answers null for bytes that do not decode, as it does for a type outside the inert set. Such a document is a row with no Open, and every other row renders as it would without it.

Regression

web/src/lib/StreamEntry.test.ts, "shows a document whose bytes do not decode with no Open, and the document beside it with its Open": a call answers with an application/pdf document whose data is %%%, beside a valid text/plain document.

Before the fix (npx vitest run src/lib/StreamEntry.test.ts on master 55c4d59c plus the test):

FAIL  src/lib/StreamEntry.test.ts > a transcript entry > shows a document whose bytes do not decode with no Open, and the document beside it with its Open
InvalidCharacterError: Invalid character
	in $effect
	in StreamFile.svelte
 ❯ blobOf src/lib/media.ts:42:17
Tests  1 failed | 15 passed (16)

After the fix, all 16 tests pass.

Golden set

None: the change draws no new scene and changes no snapshot under web/e2e.

Gates

  • sak-gate full, gate run 2, at bea784c4: passed (vitest 473/473, Playwright 799 passed, runner Playwright 10 passed).
Tracker: [#3730](https://sak.swipelab.com/tasks/3730) `blobOf` (`web/src/lib/media.ts`) decoded a base64 data URL with `atob`, which throws `InvalidCharacterError` on malformed base64. The throw escaped the file row's effect while the stream rendered, so a valid document drawn in the same pass lost its Open, and the console held the error. `blobOf` now answers null for bytes that do not decode, as it does for a type outside the inert set. Such a document is a row with no Open, and every other row renders as it would without it. ## Regression `web/src/lib/StreamEntry.test.ts`, "shows a document whose bytes do not decode with no Open, and the document beside it with its Open": a call answers with an `application/pdf` document whose data is `%%%`, beside a valid `text/plain` document. Before the fix (`npx vitest run src/lib/StreamEntry.test.ts` on master 55c4d59c plus the test): ``` FAIL src/lib/StreamEntry.test.ts > a transcript entry > shows a document whose bytes do not decode with no Open, and the document beside it with its Open InvalidCharacterError: Invalid character in $effect in StreamFile.svelte ❯ blobOf src/lib/media.ts:42:17 Tests 1 failed | 15 passed (16) ``` After the fix, all 16 tests pass. ## Golden set None: the change draws no new scene and changes no snapshot under `web/e2e`. ## Gates - `sak-gate full`, gate run 2, at bea784c4: passed (vitest 473/473, Playwright 799 passed, runner Playwright 10 passed).
agra merged commit 38f3bfc2af into master 2026-10-31 09:28:58 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sx/sak!203
No description provided.