diegosouzapw/OmniRoute · error · Error
Failed to create Command Code auth session
Error message
Failed to create Command Code auth session
What it means
createPendingCommandCodeAuthSession could not complete the INSERT into command_code_auth_sessions (or the follow-up read of the inserted row) — typically a schema/constraint violation, locked or uninitialized database, or missing table after migrations — so no pending auth session exists and the Command Code login flow must fail for this attempt.
Solutions
- Check that the command_code_auth_sessions table exists (run pending migrations)
- Inspect SQLite error output for locked-database or constraint failures and retry after resolving
- Regenerate the state hash/expiry and let the user restart the Command Code auth flow
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/lib/db/commandCodeAuth.ts:127 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/e574101fda6880f4.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/db/commandCodeAuth.ts:127
export function createPendingCommandCodeAuthSession(input: {
stateHash: string;
expiresAt: string;
}): CommandCodeAuthSafeStatus {
const id = randomUUID();
const now = nowIso();
db()
.prepare(
`INSERT INTO command_code_auth_sessions (
id, state_hash, status, encrypted_api_key, metadata_json,
created_at, expires_at, received_at, applied_at, updated_at
) VALUES (?, ?, 'pending', NULL, NULL, ?, ?, NULL, NULL, ?)`
)
.run(id, input.stateHash, now, input.expiresAt, now);
const row = db()
.prepare<AuthSessionRow>("SELECT * FROM command_code_auth_sessions WHERE id = ?")
.get(id);
if (!row) throw new Error("Failed to create Command Code auth session");
return toSafeStatus(row);
}
export function markCommandCodeAuthSessionReceived(input: {
stateHash: string;
apiKey: string;
metadata?: CommandCodeAuthMetadata;
}): CommandCodeAuthSafeStatus | null {
const now = nowIso();
markExpiredForState(input.stateHash, now);
const metadata: CommandCodeAuthMetadata = {
...(input.metadata || {}),
receivedAt: now,
};
const encryptedApiKey = encrypt(input.apiKey);
db()
.prepare(
`UPDATE command_code_auth_sessionsView on GitHub (pinned to a179ffed5b)