Known Issues and Troubleshooting¶
This document catalogs known issues, bugs, and their workarounds.
Framework Issues¶
Neuroglia MongoDB Import Bug¶
Status: Reported to framework maintainers Severity: Medium Affects: Projects using Motor (async MongoDB) without PyMongo
Description¶
The Neuroglia package neuroglia-data-motor has an import bug in its __init__.py that causes unnecessary dependency on pymongo even when using only async Motor driver.
Root Cause¶
File: neuroglia/data/motor/__init__.py
EnhancedMongoRepository requires pymongo (sync driver) but most users only need MotorRepository (async).
Impact¶
- Forces installation of unused
pymongodependency - Larger dependency tree
- Potential version conflicts
- Import fails if pymongo not installed
Workaround¶
Add pymongo to dependencies even though not directly used:
# pyproject.toml
[tool.poetry.dependencies]
neuroglia-data-motor = "^0.3.1"
pymongo = "^4.10.1" # Workaround for Neuroglia bug
Proposed Solutions¶
Three possible fixes for framework:
- Lazy Import (Recommended)
# __init__.py
__all__ = ['MotorRepository', 'EnhancedMongoRepository']
def __getattr__(name):
if name == 'MotorRepository':
from .motor_repository import MotorRepository
return MotorRepository
elif name == 'EnhancedMongoRepository':
from .enhanced_mongo_repository import EnhancedMongoRepository
return EnhancedMongoRepository
raise AttributeError(f"module {__name__} has no attribute {name}")
- Separate Package
- Create
neuroglia-data-mongofor sync operations -
Keep
neuroglia-data-motorasync-only -
Optional Dependency
try:
from .enhanced_mongo_repository import EnhancedMongoRepository
except ImportError:
EnhancedMongoRepository = None
Related Files¶
- Bug report:
docs/troubleshooting/neuroglia-mongo-import.md - Workaround in:
pyproject.toml
Environment Issues¶
Python Version Mismatch¶
Symptom: ModuleNotFoundError or import errors after environment recreation
Cause: VS Code/Pylance caching old environment
Solution:
- Reload VS Code window:
-
Cmd+Shift+P → "Developer: Reload Window"
-
Or restart VS Code completely
-
Verify Python version:
Poetry Install Hangs¶
Symptom: poetry install appears stuck
Causes:
- Large dependency resolution
- Network issues
- Lock file conflicts
Solutions:
# Clear cache
poetry cache clear pypi --all
# Try with verbose output
poetry install -vvv
# Or skip existing packages
poetry install --no-root
PYTHONPATH Issues¶
Symptom: "ModuleNotFoundError: No module named 'src'"
Solution: Ensure src/ is in PYTHONPATH
# Option 1: Export in shell
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
# Option 2: Add to .env
PYTHONPATH=/path/to/project
# Option 3: Run with python -m
python -m uvicorn src.main:app
Docker Issues¶
Port Already Allocated¶
Symptom: "port is already allocated" error
Check what's using port:
Solutions:
- Stop conflicting service
- Change port in
.env:
- Kill process using port:
Volume Mount Not Working¶
Symptom: Code changes don't trigger reload
Check mounts:
Solutions:
- Restart container:
- Rebuild without cache:
- Verify paths in
docker-compose.yml:
Redis Connection Refused¶
Symptom: "Connection refused to redis:6379"
Check Redis is running:
Solutions:
- Start Redis:
- Check network:
- Verify configuration in
.env:
Authentication Issues¶
Session Not Found (401 Errors)¶
Symptom: Authenticated user suddenly gets 401
Causes:
- Session expired (TTL reached)
- Redis restarted (sessions lost)
- Cookie not sent
Debug:
# Check Redis has sessions
docker compose exec redis redis-cli KEYS "session:*"
# Check cookie in browser DevTools
# Application → Cookies → session_id
Solutions:
- Increase TTL in settings:
- Enable Redis persistence:
- Check SameSite settings if cross-origin:
response.set_cookie(
"session_id",
value=session_id,
samesite="none", # For cross-origin
secure=True # Required with samesite=none
)
Keycloak Redirect Loop¶
Symptom: Infinite redirects between app and Keycloak
Causes:
- Wrong redirect URI configuration
- CORS issues
- Cookie not being set
Check Keycloak client config:
- Admin Console → Clients → starter-app-client
- Valid Redirect URIs:
http://localhost:8020/* - Web Origins:
http://localhost:8020
Check application config:
Must match Keycloak configuration exactly.
Database Issues¶
MongoDB Connection Timeout¶
Symptom: "ServerSelectionTimeoutError"
Check MongoDB:
Test connection:
Solutions:
- Verify connection string format:
- Check network connectivity:
- Increase timeout in Motor config:
Collection Not Found¶
Symptom: Operations fail with "collection doesn't exist"
Cause: MongoDB creates collections on first write
Solution: Collections auto-created on first document insert. For explicit creation:
Frontend Issues¶
Bootstrap Not Defined¶
Symptom: ReferenceError: bootstrap is not defined
Cause: Missing import in module
Solution: Import Bootstrap in file using it:
Module Not Found¶
Symptom: "Failed to resolve module specifier"
Causes:
- Wrong import path
- Missing file extension
- Case sensitivity
Solutions:
// ✅ Correct - relative path with extension
import { getTasks } from './api/tasks.js';
// ❌ Wrong - absolute path
import { getTasks } from '/api/tasks.js';
// ❌ Wrong - no extension
import { getTasks } from './api/tasks';
Styles Not Loading¶
Symptom: Unstyled content
Check:
- Build completed successfully:
- CSS file exists:
- HTML references CSS:
Solution: Rebuild UI:
General Debugging¶
Enable Debug Logging¶
View All Container Logs¶
Check Service Health¶
# Application health
curl http://localhost:8020/health
# MongoDB
docker compose exec mongodb mongosh --eval "db.runCommand({ping: 1})"
# Redis
docker compose exec redis redis-cli ping
# Keycloak
curl http://localhost:8090/health
Clean State Reset¶
# Stop everything
docker compose down
# Remove volumes (⚠️ deletes data)
docker compose down -v
# Rebuild
docker compose build --no-cache
# Start fresh
docker compose up -d
Getting Help¶
Check Documentation¶
- Architecture Overview - Design patterns
- Docker Environment - Environment setup
- Frontend Build Process - UI build process
Logs and Diagnostics¶
# Application logs
docker compose logs app
# All services
make docker-logs
# System info
make status
Create Issue¶
If you find a new bug:
- Check if already documented here
- Gather logs and error messages
- Create minimal reproduction steps
- Document in this file or create GitHub issue
Related Documentation¶
- Neuroglia MongoDB Bug - Detailed bug report
- Docker Environment - Service setup
- Makefile Reference - Command reference
- Getting Started - Running the application