Engineering

Four ways a sign-in handoff can return HTTP 200 and still fail

Shenameez is a desktop application. Signing in means moving a person from a browser, where they typed a password, back into a native window, where a session has to be stored. That hop is the oldest awkwardness in desktop software, and it took four separate defects before we could prove ours worked. Every one of them looked like success to at least one automated check.

Published 23 November 2026 · written by the person who built it · measured against our own running project, not a demo environment.

The design in one paragraph

The app opens the website in the default browser. The website signs the person in through Supabase. Once they have a session, the website asks a server-side function to mint a single-use code, hands that code to the app through a shenameez:// deep link, and the app trades the code for a real access and refresh pair at a second function. No bearer token ever passes through the operating system's URL handler. The code is 32 random bytes, stored only as a SHA-256 digest, valid for 60 seconds, and marked used by a single SQL statement.

That part was right the first time. Everything below is about the plumbing.

1. A function that answered 200 and did nothing

Supabase's dashboard offers to create an Edge Function from a template. The template replies {"message":"Hello undefined admin!"} with status 200. Our deployment check looked only at status codes, so it reported the function as live. It was live. It was also the template.

The check now reads the body and fails loudly on that phrase. A status code describes the transport, never the behaviour, and a health check that cannot tell the difference between a working service and a greeting is worse than no check, because it manufactures confidence.

2. A token in the wrong slot

The minting function needs to confirm the caller is really signed in. The obvious code is createClient(url, accessToken) followed by getUser(). It rejected every legitimate session.

The second argument of that constructor is the apikey, not the user's credential. Putting a bearer token there means the API gateway inspects it as a gateway key, fails, and the function never sees the session at all. The two headers are different things and had been quietly merged into one in my head.

The fix asks the auth service directly, sending the gateway key as apikey and the person's token as Authorization. It is three lines instead of two and it is unambiguous about which credential does what.

3. An endpoint that does not exist

Turning the one-time code into a session requires minting a token for the account and then verifying it. The admin reference names a verify endpoint under the admin path. It returns 404. It is not there.

Two further probes found the real shape: the public verify route rejects a body containing only a token hash with "requires a verification type", and accepts the same body once a type is named. Nothing in the documentation I had read said the admin and public paths differed here. The only thing that settled it was calling them.

The lesson is not "read the docs harder". It is that an undocumented-by-assumption API surface should be treated as unknown until observed, and the observation should be written into the code comment so the next reader does not re-derive it.

4. An object shape nobody unpacked

The last defect was found today, and it is the reason the desktop sign-in does not complete yet. The redemption function fetched the account by id and read the email address off the response. The client library returns { data: { user: { email } } }. The code destructured data, named it user, and read user.email — which is undefined, because email sits one level deeper.

A missing email address triggered the generic "link is no longer valid" failure, which is the correct message to show a stranger and exactly the wrong thing for a developer to debug from. The function was fixed to call the REST endpoints directly and to name the failing stage in its response, so a broken deployment can no longer hide behind one vague 400.

What we verified, and what we did not

These were tested against the running project, not asserted from the source:

01

Single use

Redeeming the same code a second time is refused. The claim is one UPDATE that re-checks the used timestamp under the row lock, so two simultaneous attempts cannot both win.

02

Rate limit

Five handoffs per account per minute. The count is checked before the code is minted, so the attempt that would exceed the window is the one refused -- in testing the fifth request came back with a wait message. That is how we know the limit is five and not four.

03

Callback allow-list

A minting request naming an off-site address is refused. Without that check the function would redirect a signed-in person anywhere the request body said.

04

No anonymous mint

Presenting only the server key, with no session, produces 401. The key can insert a row; it cannot conjure a session for someone who has not signed in.

What is not verified: the full round trip on the corrected build. The redeployed redemption function has to be published before the end-to-end check passes, and until it is, the desktop app cannot complete a browser sign-in. We are not going to describe a flow as working because the source on disk looks right.

The pattern underneath all four

Every defect was a case of two components agreeing on a status code while disagreeing about what was inside the body. A greeting and a session are both 200. A refused login and an expired link are both 400. An object and a wrapper around that object both destructure without error.

So the standing rule on this project is that a check has to name the thing it actually observed. Not "the endpoint responded" — "the endpoint returned a token whose subject matches the account that asked for it". That single change is what turned four silent failures into four lines of output that said where the problem was.

Try the software, not the write-up

The application runs locally and is free to install.