Quick Diagnostics
Run the built-in health check:lm doctor checks your config file, API key, database, authentication status, and system requirements.
Debug Logging
Enable detailed logging for any command:Authentication Issues
API key not found
API key not found
Error: Get your key from Settings > API.
LeadMagic API key not foundSolutions:- Set your API key:
- Or use an environment variable:
- Verify it’s set:
Session expired
Session expired
Error: OAuth tokens expire periodically. The CLI attempts automatic refresh, but if that fails, a fresh login is needed.
Session expired or Token refresh failedSolution: Sign in again:Login browser doesn't open
Login browser doesn't open
Possible causes:
- No default browser configured
- Running in a headless environment (SSH, Docker)
Database Issues
Database locked
Database locked
Error: Or without confirmation:
Database is locked or Could not set lockCause: Another lm process is holding the database lock.Solutions:- Unlock the database:
- If that doesn’t work, check for orphaned processes:
Database corruption
Database corruption
Error: Exported files in
WAL corruption, schema mismatch, or database errors.Solutions:- Repair (preserves data when possible):
- Reset (destructive — drops all tables):
.leadmagic/export/ are not affected by reset.Database too large
Database too large
Solution: Compact the database to reclaim space:This runs
VACUUM, updates statistics, and flushes the write-ahead log.File and Data Issues
File too large
File too large
The CLI enforces row limits for safety:
Solutions:
| Rows | Behavior |
|---|---|
| 1–5,000 | Normal processing |
| 5,001–10,000 | Warning prompt before processing |
| 10,001+ | Hard stop — file is too large |
- Split large files before loading
- Filter rows using SQL after loading a subset
- Use the REST API directly for large-scale batch processing
CSV parsing errors
CSV parsing errors
Common causes:
- Non-standard delimiters (the CLI auto-detects commas, tabs, semicolons, and pipes)
- Encoding issues (the CLI handles UTF-8 and BOM)
- Malformed quotes or escaped characters
- Try analyzing the file first:
- Check the file encoding — the CLI works best with UTF-8.
- If the file uses an unusual delimiter, the CLI auto-detects it in most cases. If detection fails, pre-process the file to use standard CSV formatting.
Columns not detected
Columns not detected
Cause: Column names don’t match expected patterns (e.g.,
email, first_name, company).Solutions:- Specify columns explicitly with
--email-column,--first-name-column, etc. when usinglm enrich - In chat, tell the AI which column contains what: “The email addresses are in column C”
- Run
lm analyzeto see what the CLI detected
Connection Issues
API request failed
API request failed
Possible causes:
- No internet connection
- LeadMagic API is temporarily down
- API key is invalid or expired
- Check your internet connection
- Verify your API key:
- Check the API status at leadmagic.io/status
AI chat not responding
AI chat not responding
Cause: The AI Gateway (
ai.leadmagic.io) may be unreachable.Solutions:- Check you’re logged in:
- Re-authenticate:
- Try with debug logging to see the actual error:
Common Error Messages
| Error | Cause | Solution |
|---|---|---|
API key not found | No key configured | lm config set apiKey |
Session expired | OAuth token expired | lm login |
Database is locked | Another process holds the lock | lm db unlock |
File exceeds row limit | CSV has >10,000 rows | Split the file or use the API directly |
Insufficient credits | No credits remaining | Purchase credits |
Command not found: lm | CLI not in PATH | Open a new terminal or source ~/.zshrc |