Skip to content

fix(hub-client): abandon document open on auth failure#269

Merged
shikokuchuo merged 2 commits into
mainfrom
bugfix/resolve-actor-id-401
Jun 10, 2026
Merged

fix(hub-client): abandon document open on auth failure#269
shikokuchuo merged 2 commits into
mainfrom
bugfix/resolve-actor-id-401

Conversation

@shikokuchuo

@shikokuchuo shikokuchuo commented Jun 10, 2026

Copy link
Copy Markdown
Member

When a sign-in session expired mid-use, opening any document silently succeeded with the wrong collaboration identity. The document-open paths call resolveActorId and bail out only when it returns null.

But on a 401/403, resolveActorId returned undefined — not null — so the guard never fired. This is only when the code had already started a token refresh and meant to abandon the attempt.

The fix moves resolveActorId into authService with an explicit three-valued contract:

  • string → actor ID resolved; open with it
  • undefined → auth disabled; open with no actor ID
  • null → auth failure; abandon the open

Returning null on a 401/403 makes the existing === null guard fire, so the open is cleanly abandoned while the silent refresh runs.

Regression from 465de01 (bd-3o8zmz46); covered by new unit tests for the contract.

resolveActorId returned undefined on a 401/403, but every open call site
guards on === null, so a mid-session expiry opened the document with a
random Automerge actor ID instead of abandoning. Extract resolveActorId
into authService with an explicit three-valued contract (string / undefined
/ null) and return null on auth failure so the guard fires. Regression from
465de01 (bd-3o8zmz46).
@shikokuchuo shikokuchuo merged commit e628a18 into main Jun 10, 2026
4 of 5 checks passed
@shikokuchuo shikokuchuo deleted the bugfix/resolve-actor-id-401 branch June 10, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant