Skip to content

fix(e2e): write the auth session under the key supabase-js actually reads - #578

Merged
thinkclay merged 1 commit into
mainfrom
claude/kanban-hooks
Aug 12, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/kanban-hooks

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Found while working #577. The premise of that issue was wrong, and this is the real blocker — see below.

The bug

auth.setup.ts derived the localStorage key by replacing every . and : in the full host:

new URL(url).host.replace(/[.:]/g, '-')   // -> sb-127-0-0-1-54321-auth-token

supabase-js uses the first hostname label — sb-127-auth-token locally, and the project ref for a hosted URL (abc123.supabase.co → sb-abc123-auth-token).

So every storage state this setup has ever written held a perfectly valid session under a key the client never reads. Specs authenticated, saved state, loaded it, and rendered the login screen.

Three derivations were wrong — one helper and two in-page copies. All now use the same rule. Verified concretely: admin.json and user.json now contain sb-127-auth-token where they previously contained the long form.

#577 was misdiagnosed — by me

I filed #577 saying ApplicationsKanbanBoard renders no test hooks and the helpers wait on selectors that match nothing. That is not true. @scaffald/ui's KanbanColumn and KanbanCard already set testID={kanban-column-${id}} and kanban-card-${id}, and those are present in the built output.

What actually happened: the spec never reached the board, so I inferred a selector mismatch from an empty page snapshot instead of checking the component. Correcting it on the issue.

This is not verified end to end, and it cannot be on this machine

The local Supabase container's clock is 26 hours behind the host, so every token it issues is already expired by browser time:

token iat=1786405275  exp=1786408875
host  now=1786498798     ->  26.0 hours behind

Any browser session built from those tokens is dead on arrival regardless of which key it is stored under. That skew also produced the JWT issued at future rejections PostgREST returned earlier in this work.

The fix above is correct on its own terms and verified at the level it can be — the right key is now written. Proving the specs go green needs a machine whose container clock is sane, which is a docker/Supabase restart, not a code change.

What is still needed for the office suite

  1. This PR — session stored under a readable key.
  2. A sane container clock on whatever machine runs it.
  3. Then re-check whether any selector work is needed at all. My guess now is little to none, but that is a guess and it should be measured rather than asserted.

…eads

auth.setup.ts derived the localStorage key by replacing every '.' and ':'
in the full host, producing `sb-127-0-0-1-54321-auth-token`. supabase-js
uses the first hostname label — `sb-127-auth-token` locally, and the
project ref for a hosted URL (`abc123.supabase.co` -> `sb-abc123-...`).

So every storage state this setup has written held a valid session under a
key the client never reads. Specs authenticated successfully and then
rendered the login screen, which is what #577 was filed against.

Three derivations were wrong — one helper and two in-page copies. All now
use the same rule. Verified: admin.json and user.json now contain
`sb-127-auth-token` where they previously contained the long form.

Not verified end to end, and it cannot be here. This machine's Supabase
container clock is 26 hours behind the host, so every token it issues is
already expired by browser time:

  token iat=1786405275 exp=1786408875
  host  now=1786498798

Any browser session built from those tokens is dead on arrival regardless
of which key it is stored under. That is also what produced the earlier
"JWT issued at future" rejections from PostgREST. The fix above is correct
independently; proving it needs a machine whose container clock is sane.
@thinkclay

Copy link
Copy Markdown
Contributor Author

Not merging this yet — CI cannot run. Every workflow across the repo has been failing since ~00:28 UTC, main included:

01:14  CI                main -> failure
01:14  Deploy Web App    main -> failure
01:14  Main Guard        main -> failure
01:14  Release           main -> failure

The failing jobs have zero steps and complete in 1 second with no logs and no annotations — the signature of Actions being unable to start jobs, not of a code failure. main's CI passed at 00:01 and has failed on every run since. Likely the org's Actions minutes; I have run a lot of CI today.

I am leaving this open rather than merging on an unverifiable green. Merging changes whose checks cannot execute is the exact failure mode this epic has been about.

Verified locally in the meantime:

  • tsc --noEmit clean for the touched file.
  • The setup project still selects its 3 tests.
  • The key it writes is now sb-127-auth-token, matching what supabase-js reads; admin.json and user.json confirm it.

Ready to merge once Actions is working — or on your say-so if you would rather not wait.

@thinkclay
thinkclay merged commit 0ad323c into main Aug 12, 2026
9 of 13 checks passed
@thinkclay
thinkclay deleted the claude/kanban-hooks branch August 12, 2026 02:51
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