The dollar sign that broke my authentication hostname
My authentication adapter built a hostname with a dollar sign at the end. The sign wasn’t visible at the place the code tried to remove it.
The hostname came from decoding part of a Clerk publishable key. My code split the encoded text at $, then decoded what remained. But the sentinel belonged to the decoded value.
The June 27 fix moves the cleanup to the representation where the character exists.

Illustration: a marker becomes visible after unpacking.
Follow the value through decoding
Here is a fabricated key for a dummy hostname:
pk_test_YXV0aC5leGFtcGxlLmNvbSQ
The encoded portion represents:
auth.example.com$
There is no literal dollar sign in the encoded portion. Splitting that text at $ leaves it unchanged. Decoding then produces the hostname with the unwanted trailing character still attached.
The fix removes the test or live prefix, supplies the required base64 padding, decodes the value, and strips one trailing sentinel from the decoded text:
padding = "=" * (-len(domain_part) % 4)
decoded = base64.b64decode(domain_part + padding).decode("utf-8")
domain = decoded[:-1] if decoded.endswith("$") else decoded
The order carries the repair. Cleaning the wrong representation can leave every line of code looking reasonable while changing nothing about the failing value.
The failure happens before token verification can finish
The adapter uses that domain to construct the JWKS URL, where it obtains public keys used for token verification. A wrong host interferes with retrieving the keys before the application can finish checking the user’s token.
That is different from a bad signature or a user lacking the author role. All can prevent access, but they belong to different parts of the authentication path.
The code now handles the pk_test_ and pk_live_ prefixes through the same decoding branch. That gives the sentinel rule one place to live rather than duplicating it across two nearly identical blocks.
A regression case needs the encoded sentinel
A useful test fixture would start with a dummy hostname ending in $, encode it, and construct a publishable-key-shaped input. The expected domain should be the dummy hostname without the sentinel.
Testing only a decoded hostname with a dollar sign wouldn’t exercise the earlier mistake. The test has to cross the boundary where the representation changes.
I would also keep a case without the sentinel, so the cleanup doesn’t remove a valid final hostname character. The new conditional is deliberately narrower than dropping the last character of every decoded value.
The cleanup had been looking for the sentinel before decoding produced it.