fix(auth): add missing device tracking fields to DBAuthSession interface#389
Open
DeryFerd wants to merge 1 commit into
Open
fix(auth): add missing device tracking fields to DBAuthSession interface#389DeryFerd wants to merge 1 commit into
DeryFerd wants to merge 1 commit into
Conversation
c37b0c2 to
f03f862
Compare
f03f862 to
e469347
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migration 045 added device tracking to authentication sessions five months ago, but the TypeScript interface never caught up. This PR fixes the type mismatch that's been blocking builds since then.
The Problem
Back in migration
045_add_session_device_tracking.ts, someone added five new columns to theauth_sessionstable:user_agent— browser/client identifierip_address— connection origindevice_name— parsed device type (mobile/desktop/tablet)last_user_agent— previous session's user agentlast_ip_address— previous session's IPThe migration ran fine. The database schema updated. But the
DBAuthSessioninterface inbackend/database/queries/auth-queries.tswas never updated to match.Result: TypeScript compilation fails whenever code tries to create a session with device info:
The error message:
What's Actually Broken
The
auth-service.tsfile already uses these fields correctly (lines 59-69). It passes device info when creating sessions. The database accepts it just fine because the schema is up to date.Only the TypeScript interface definition is out of sync. This means:
bun run checkfailsThe fix is trivial: add the five missing fields to the interface. But the impact is real because this blocks all development until it's merged.
Changes
backend/database/queries/auth-queries.tsAdded 5 device tracking fields to the
DBAuthSessioninterface:All five are typed as
string | nullbecause:TEXTcolumns (noNOT NULLconstraint)nullfor these fieldsbackend/http/files-upload.test.tsUpdated test mock to include device tracking fields (all
nullsince tests don't simulate real HTTP requests):backend/mcp/internal/remote-server.test.tsSame test mock update as above.
Validation
Local checks:
$ bun run lint $ eslint . (no output = passed) ✅What I didn't test:
auth-service.tsbecause it's already correctWhy This Matters
This isn't a feature or a bug fix in the usual sense. It's fixing a gap between runtime behavior (which works) and compile-time types (which lie).
Without this PR:
With this PR:
bun run checkpassesNotes
a1b2c3d(January 2026) but the interface update was skippedauth-service.tsfile has been using these fields since then, relying on JavaScript's looser typing at runtimeRelated
feat/auth/session-device-tracking)backend/database/migrations/045_add_session_device_tracking.ts