Skip to content

Fix critical database schema bugs in email-agent#55

Open
verkyyi wants to merge 3 commits intoanthropics:mainfrom
verkyyi:fix/critical-database-bugs
Open

Fix critical database schema bugs in email-agent#55
verkyyi wants to merge 3 commits intoanthropics:mainfrom
verkyyi:fix/critical-database-bugs

Conversation

@verkyyi
Copy link
Copy Markdown

@verkyyi verkyyi commented Feb 16, 2026

Problem

The email-agent has critical database schema bugs that break core functionality:

  1. Email search completely broken - SQLiteError: table emails has no column named to_addresses
  2. Email sync fails - Missing imap_uid column
  3. Listener details UI broken - File path mismatch errors

Root Cause

The codebase has two incompatible database implementations:

  • email-db.ts - Uses normalized recipients table
  • database-manager.ts - Expects denormalized address columns in emails table

Search endpoint uses DatabaseManager while sync uses EmailDatabase → schema mismatch.

Changes

1. Add missing imap_uid column (database/email-db.ts)

  • Required by EmailSyncService but missing from schema
  • Fixes: Email sync errors on fresh databases

2. Add address compatibility columns (database/migrations/add-address-columns.sql)

  • Adds to_addresses, cc_addresses, bcc_addresses columns
  • Migration populates from existing recipients table
  • Fixes: All email search functionality

3. Fix listener ID mismatch (finance-email-tracker.ts)

  • Change finance_email_trackerfinance-email-tracker to match filename
  • Fixes: UI errors when loading listener details

Testing

✅ Tested with fresh database - email sync works
✅ Tested with 40+ synced emails - search returns results
✅ Tested listener UI - details page loads without errors
✅ Migration successfully populates address columns from recipients data

Impact

Before: Email search unusable, sync broken, UI errors
After: All functionality works correctly

This is a compatibility shim until the codebase is refactored to use a single database abstraction.

Related Issues

This fixes the database schema incompatibility that affects all users trying to use the email-agent demo.

verkyyi and others added 3 commits February 16, 2026 21:29
## Critical Bug Fixes

### 1. Add missing imap_uid column
- EmailSyncService requires imap_uid but email-db.ts schema was missing it
- Prevents "SQLiteError: table emails has no column named imap_uid" during email sync
- **Impact:** Email sync was broken for new databases

### 2. Fix schema incompatibility: email-db vs database-manager
- email-db.ts creates separate `recipients` table
- database-manager.ts expects `to_addresses`, `cc_addresses`, `bcc_addresses` columns in emails table
- Search endpoint uses DatabaseManager → search was completely broken
- Added migration to create missing columns and populate from recipients table

**Error fixed:** "SQLiteError: table emails has no column named to_addresses"
**Impact:** All email search functionality was broken

### 3. Fix listener ID/filename mismatch
- Listener ID was `finance_email_tracker` (underscore)
- Filename is `finance-email-tracker.ts` (hyphen)
- UI couldn't load listener source code (ENOENT error)
- **Impact:** Listener details page showed errors

## Root Cause Analysis

The codebase has two competing database implementations:
1. `email-db.ts` - Uses normalized `recipients` table (newer)
2. `database-manager.ts` - Uses denormalized address columns (legacy)

Different endpoints use different implementations, causing incompatibility.
This PR adds address columns as a compatibility shim until codebase
is refactored to use a single database abstraction.

## Testing
- ✅ Email sync works without imap_uid errors
- ✅ Email search returns results (tested with 40+ emails)
- ✅ Listener details page loads without file errors
- ✅ Migration populates address columns from existing data

Fixes anthropics/claude-agent-sdk-demos#[issue-number-if-exists]

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Auto Apply button on each job card tailors resume + generates cover
  letter + auto-opens the job posting URL when complete
- Batch Auto Apply queue in Saved Jobs tab processes multiple jobs
  sequentially, skipping already-applied positions
- Cover letter generation via Claude: personalized to role/company using
  the same web research done during resume tailoring
- Enhanced tailor modal with auto-apply badge, cover letter preview/copy,
  and "Open Job Posting" button
- Applications tab now shows auto-applied badge, cover letter download,
  job posting link, and a "Tailored" status option
- Fixed job tracking bug where showTailorComplete used searchResults[0]
  instead of the job being processed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant