-
Notifications
You must be signed in to change notification settings - Fork 0
TROUBLESHOOTING
Nick edited this page Mar 10, 2026
·
1 revision
Troubleshooting
Symptoms:
-
curl http://localhost:8000/api/v1/healthnot working - Connection refused
Solution:
- Check if the server is running:
ps aux | grep uvicorn - Check the port:
lsof -i :8000
- Restart the server:
poetry run uvicorn app.api.main:app --host 0.0.0.0 --port 8000
Symptoms:
{"detail": "Empty messages list"}{"detail": "Invalid data"}
Solution:
- Check request format:
# Correct { "messages": [ {"id": "1", "text": "message", "is_spam": True} ] } # Incorrect { "message": {...} # Should be "messages" (plural) }
- Проверьте обязательные поля:
textrequired - Проверьте типы данных:
is_spammust be boolean
Symptoms:
{"detail": "Pattern mining failed: ..."}
Solution:
- Check server logs
- Check database connection:
# Check DATABASE_URL in .env echo $DATABASE_URL
- Check database availability:
sqlite3 data/spamapi.db "SELECT COUNT(*) FROM messages;"
Symptoms:
-
patterns_created: 0after mining - no patterns in response
Solution:
- Check if there are spam messages:
# Check via API response = requests.get("http://localhost:8000/api/v1/patterns")
- Decrease
min_spam_count:requests.post( "http://localhost:8000/api/v1/patterns/mine", json={"min_spam_count": 3} # Instead of 10 )
- Check if messages are marked as spam:
# Ensure is_spam=True in messages
Symptoms:
- Mining takes a long time
- Timeout errors
Solution:
- Decrease
days:requests.post( "http://localhost:8000/api/v1/patterns/mine", json={"days": 1} # Instead of 7 )
- Disable LLM:
json={"use_llm": False}
- Decrease
PATTERN_MINING_CHUNK_SIZEв .env
Symptoms:
-
promoted_count: 0after promote - Rules remain in shadow status
Solution:
- Check rule metrics:
response = requests.get( "http://localhost:8000/api/v1/rules", params={"status": "shadow", "include_evaluation": True} ) rules = response.json() for rule in rules: eval_data = rule.get("evaluation") if eval_data: print(f"Rule {rule['id']}: precision={eval_data.get('precision')}")
- Check
AGGRESSIVENESS_PROFILE:# Conservative requires precision >= 0.95 # if precision < 0.95, rules are not promoted
- Ensure rules were evaluated:
requests.post("http://localhost:8000/api/v1/rules/eval-shadow")
Symptoms:
-
precision: 0.50or lower - Many ham hits
Solution:
- Check rule SQL expression:
response = requests.get("http://localhost:8000/api/v1/rules") for rule in response.json(): print(f"Rule {rule['id']}: {rule['sql_expression']}")
- Use LLM validation:
# Enable LLM validation during mining requests.post( "http://localhost:8000/api/v1/patterns/mine", json={"use_llm": True, "enable_llm_validation": True} )
- Используйте conservative profile for stricter rules
Symptoms:
-
use_llm: truebut LLM is not used - Errors during LLM calls
Solution:
- Check API key:
echo $OPENAI_API_KEY # or echo $PATAS_OPENAI_API_KEY
- Проверьте
LLM_PROVIDER:# Should be "openai", not "none" grep LLM_PROVIDER .env - Check network access:
curl https://api.openai.com/v1/models \ -H "Authorization: Bearer $OPENAI_API_KEY"
Symptoms:
- LLM calls take a long time
- Timeout errors
Solution:
- Use a faster model:
LLM_MODEL=gpt-4o-mini # Instead of gpt-4 - Decrease количество примеров for LLM
- Use semantic mining instead of LLM for some patterns
Symptoms:
sqlalchemy.exc.OperationalError- Database locked
Solution:
- Проверьте
DATABASE_URL:echo $DATABASE_URL
- Check database access permissions:
ls -la data/spamapi.db
- for SQLite, ensure no other processes are using the database
Symptoms:
- Tables not created
- Schema errors
Solution:
- Initialize database:
from app.database import init_db import asyncio asyncio.run(init_db())
- or via CLI:
poetry run python -c "from app.database import init_db; import asyncio; asyncio.run(init_db())"
Symptoms:
- Changes in .env not working
- Old values are being used
Solution:
- Restart server after changing .env
- Check if .env is loaded:
from app.config import settings print(settings.aggressiveness_profile)
- Ensure .env is in the correct directory
Symptoms:
- Requests take a long time
- High latency
Solution:
- Use batch endpoints for large datasets
- Decrease
PATTERN_MINING_CHUNK_SIZE - Disable LLM if not нужен
- Use async for multiple requests
- Check database performance
if Problem not resolved:
-
Check logs:
tail -f logs/app.log
-
Check health endpoint:
curl http://localhost:8000/api/v1/health
-
Create an issue с:
- Problem description
- Logs
- Configuration (without secrets)
- Steps to reproduce
- API Reference — API documentation
- Configuration Guide — settings
- Integration Guide — Integration