Database issues
Connection refused or database not available
Connection refused or database not available
Symptoms:
- Application fails to start
- Error:
connection refusedorcould not connect to server
-
Verify Docker container is running:
You should see a PostgreSQL container running. If not, start it:
-
Check DATABASE_URL configuration:
- Verify the connection string format:
postgresql://user:pass@host:port/database - Confirm the port matches your Docker configuration (default: 5435)
- Ensure credentials match your docker-compose.yml
- Verify the connection string format:
-
Test database connectivity:
-
Check Docker logs:
pgvector extension not found
pgvector extension not found
Symptoms:
- Error:
type "vector" does not exist - Error:
extension "vector" does not exist
-
Verify pgvector is installed:
Connect to your database and run:
-
Create the extension:
The application attempts to create it automatically in
app/main.py, but you can create it manually: -
Use the correct Docker image:
Ensure your
docker-compose.ymluses a PostgreSQL image with pgvector:
The extension must be created before running migrations or creating tables with vector columns.
Vector dimension mismatch
Vector dimension mismatch
Symptoms:
- Error:
expected 3072 dimensions, not X
- Your database schema defines vector columns as
vector(3072) - You’re using the correct embedding model:
gemini-embedding-001 - You haven’t mixed embeddings from different models
- Drop existing embeddings
- Update the vector column dimension
- Regenerate all embeddings
API key and authentication issues
Invalid or missing API keys
Invalid or missing API keys
Symptoms:
- Error:
API key not valid - Error:
401 Unauthorizedfrom AI providers - Application startup validation error
-
Verify API keys are set:
-
Validate API keys:
- Gemini: Visit Google AI Studio and verify your key
- Anthropic: Visit Anthropic Console and check your key status
-
Check for whitespace or quotes:
In your
.envfile, ensure no extra spaces or quotes: - Regenerate keys if necessary: If keys are compromised or invalid, generate new ones from the respective consoles.
JWT token errors
JWT token errors
Symptoms:
- Error:
Could not validate credentials - Error:
Signature verification failed - Users unexpectedly logged out
-
Verify JWT_SECRET is set:
Should return a number > 16 (ideally 32+)
-
Check for secret rotation:
If you changed
JWT_SECRET, all existing tokens become invalid. Users must log in again. -
Verify token expiration:
Check
ACCESS_TOKEN_EXPIRE_MINUTESsetting. Tokens expire after this duration. -
Test token generation:
LLM and embedding issues
LLM failover not working
LLM failover not working
Symptoms:
- Application crashes when Gemini fails
- No automatic fallback to Claude
- Error messages about unavailable services
-
Verify both API keys are configured:
-
Check LLM service configuration:
The failover hierarchy is defined in
app/services/llm_service.py:13-26. Verify the configuration:- Google models are tried first
- Anthropic models are fallback
-
Review error handling:
The service catches
APIStatusErrorandAPIConnectionError. Other exceptions may not trigger failover. -
Check application logs:
Look for warning messages indicating failover attempts:
Failover only occurs during answer generation. Embeddings always use Gemini and do not have a fallback.
Embedding generation fails
Embedding generation fails
Symptoms:
- Error:
Error al generar embedding - Search returns no results
- Products cannot be indexed
-
Verify Gemini API key:
Embeddings require a valid
GEMINI_API_KEY. There is no fallback. - Check API quota: You may have exceeded your free tier quota. Check Google AI Studio usage.
-
Validate input text:
- Text should not be empty
- Very long text (>10,000 characters) may fail
- Special characters are handled, but extreme cases may cause issues
-
Test embedding generation directly:
Should output:
Embedding dimension: 3072
Rate limiting or quota exceeded
Rate limiting or quota exceeded
Symptoms:
- Error:
429 Too Many Requests - Error:
Quota exceeded - Intermittent failures during high usage
-
Check quota usage:
- Gemini: Google AI Studio
- Anthropic: Console Usage
-
Implement caching:
Cache embeddings and LLM responses to reduce API calls:
- Store embeddings in database (already done for products)
- Cache search results for common queries
- Use Redis or similar for response caching
- Upgrade your plan: Consider upgrading to paid tiers for higher quotas.
- Implement rate limiting: Add rate limiting to your API endpoints to control request volume.
Development environment issues
Import errors or missing dependencies
Import errors or missing dependencies
Symptoms:
- Error:
ModuleNotFoundError: No module named 'X' - Import errors when starting the application
-
Verify virtual environment is activated:
-
Install dependencies:
-
Check Python version:
The project requires Python 3.13+:
-
Reinstall dependencies:
If issues persist, recreate the virtual environment:
CORS errors in browser
CORS errors in browser
Symptoms:
- Error:
Access to fetch at ... has been blocked by CORS policy - Frontend cannot connect to API
-
Verify CORS configuration:
Check
app/main.py:17-23for CORS middleware settings. -
Add your frontend origin:
Update
allow_originsto include your frontend URL: -
For development, allow all origins:
Application won't start or crashes immediately
Application won't start or crashes immediately
Symptoms:
- Application exits immediately after starting
- Validation errors on startup
- Cryptic error messages
-
Check for configuration errors:
Most startup failures are due to missing or invalid configuration:
This will show validation errors clearly.
-
Verify database connection:
Test the database before starting the app:
-
Check for port conflicts:
If port 8000 is in use:
-
Review application logs:
Run with verbose logging:
Getting help
If you encounter issues not covered here:- Check application logs: Most errors include detailed stack traces
- Enable debug mode: Set
--log-level debugwhen running uvicorn - Verify configuration: Use the configuration validation script
- Test components individually: Isolate the failing component (database, LLM, auth)