wandb/openui · error · TypeError
Unkown error: ${String(error)}
Error message
Unkown error: ${String(error)} What it means
register() catches errors from the WebAuthn flow; if the message contains 'User already exists' it returns false, otherwise it rethrows. If the caught value is NOT an Error instance (else branch) it wraps it in a TypeError with 'Unkown error: <string>'. This happens when a non-Error (string, DOMException-like value, undefined) is thrown or rejected.
Source
Thrown at frontend/src/api/openui.ts:189
true
)) as PublicKeyCredentialCreationOptions
console.log('registration response:', publicKey.user, typeof publicKey.user)
publicKey.user.id = asArrayBuffer(publicKey.user.id as unknown as string)
publicKey.challenge = asArrayBuffer(
publicKey.challenge as unknown as string
)
const creds = await navigator.credentials.create({ publicKey })
await post(username, creds as PublicKeyCredential, true)
return true
} catch (error) {
if (error instanceof Error) {
// TODO: this is hacky but works
if (error.toString().includes('User already exists')) {
return false
}
throw error
} else {
throw new TypeError(`Unkown error: ${String(error)}`)
}
}
}
export async function auth(username: string): Promise<boolean> {
const publicKey = (await getPublicKey(
username
)) as PublicKeyCredentialRequestOptions
console.log('auth get response:', publicKey)
publicKey.challenge = asArrayBuffer(publicKey.challenge as unknown as string)
if (
publicKey.allowCredentials !== undefined &&
publicKey.allowCredentials.length > 0
) {
publicKey.allowCredentials[0].id = asArrayBuffer(
publicKey.allowCredentials[0].id as unknown as string
)
// TODO: if a user attempts to re-register they'll be given the optionView on GitHub (pinned to 42d7ab4ab6)
Solutions
- Normalize caught values with `error instanceof Error ? error : new Error(String(error))` before branching.
- Keep the 'User already exists' substring check but base it on String(error).
- Fix the typo 'Unkown' → 'Unknown' when surfacing the message.
- Log the raw thrown value to identify which browser/path produces non-Error rejections.
Example fix
// before
throw new TypeError(`Unkown error: ${String(error)}`)
// after
throw error instanceof Error
? error
: new Error(`Unknown error: ${String(error)}`) Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof username !== 'string' || username.length === 0) throw new Error('Username required') Type guard
function isError(v: unknown): v is Error {
return v instanceof Error
} Try / catch
try {
await register(username)
} catch (e) {
if (String(e).includes('User already exists')) return false
if (e instanceof Error) throw e
throw new Error(`Unknown error: ${String(e)}`)
} Prevention
- Normalize all caught values with instanceof Error before branching
- Check for existing users before registering
- Log raw thrown values to catch browser-specific non-Error rejections
When it happens
Trigger: The WebAuthn ceremony rejects with a non-Error value (e.g. NotAllowedError is fine, but some browsers/polyfills throw strings); or getPublicKey/post reject with undefined.
Common situations: User cancels the passkey prompt in browsers that throw non-Error values; older Safari/Chrome WebAuthn quirks; promise rejection with a plain string from a custom layer.
Related errors
- Unexpected response ${r.status}: ${await r.text()}
- Unexpected response ${req.status}: ${await req.text()}
- No credential ID found
- body.error.message
AI-assisted analysis of wandb/openui@42d7ab4ab6 (2026-09-01).
Data as JSON: /api/errors/eb9e0b0f2b6d0ce0.
Report an issue: GitHub.