Skip to content

The session=<File> decoder branch is unreachable from its only caller #519

Description

@turner

What was found

extractConfig has a branch for a session value that is a File object — urlUtils.js:90-104, isFile(sessionValue), reading await sessionValue.text() and handling both the compressed and plain-JSON forms with its own error wrapping.

It can never fire. The only caller is init.js:50, which passes window.location.href — a string. extractQuery builds its result with query[tokens[0]] = tokens[1] off String.prototype.split, so every value it can produce is a string, and isFile is false for all of them.

Found while harvesting the fixture corpus (#502, PR #517). The corpus keeps three fixtures for the branch (synth-session-file-plain-json, synth-session-file-blob-prefixed, reject-session-file-invalid-json) precisely because omitting them would have described the decoder someone meant to write rather than the one that exists. They are the only fixtures in the corpus that cannot be re-measured on each test run.

Why it is filed as a bug rather than dead code

docs/url.md lists "a session file" as an accepted form, and ADR-0006 decision 1 froze the contract as "the decoder's currently-accepted set". The spec therefore promises a form the code cannot deliver. That is a spec/code divergence, not merely an unused branch — and it is the kind that survives a refactor because a reader collapsing the decoders will faithfully carry the branch across.

The decision to make

ready-for-human because the fix depends on an unmade decision about intent:

  1. It was meant to work — a host handing init() a File, or a drag-and-drop session load. Then the fix is at the caller: something has to reach extractConfig with a non-string session, and init.js currently cannot. Note that a host wanting this today already has a working path — parse the file itself and call restoreSession, which is what Spacewalk does (see The session= wire format has two decoders, and they accept different sets #518).
  2. It was never reachable and the branch is speculative. Then delete it, and delete the session-file row from docs/url.md — the accepted set shrinks by one form that was never in it, which is a correction to the frozen contract rather than a breach of it.

Option 2 looks right, but the branch's error wrapping is more careful than the blob:/data: arm beside it (which throws bare — see reject-session-blob-corrupt), which reads like someone had a real case in mind.

Sequencing

Either way this should land after #503's golden-file snapshot, so the change is visible as a snapshot movement. It is not a blocker for #504 or #505; a decoder collapse can carry the branch across unchanged and this can be resolved on either side of it.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions