Troubleshooting Guide
Common issues and solutions for the SmartRunning Training Optimization Platform.
Runner Creation & Onboarding Issues
Missing Default Values (PBs, Heart Rate Zones)
Symptoms: New runners created through onboarding have no PB values or performance metrics
Solution: Fixed in latest version - all runner creation paths now use centralized runner_service.py
- Ensures consistent defaults for personal bests across multiple distances
- Auto-calculates performance metrics from default PBs
- Applies heart rate zones based on age
JavaScript Errors on Onboarding Page
Symptoms: Console errors like "Cannot set properties of null" on /onboarding
Solution: Fixed - app.js now skips initialization for onboarding page
- Onboarding has its own JavaScript separate from main app
- Defensive null checks added for all element references
MongoDB Connection Issues
Connection Failed / Timeout
Symptoms: Application fails to start, logs show "Failed to connect to MongoDB"
Solutions:
-
Verify connection string in
.envfile# Check your .env file has:
MONGO_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/
DATABASE_NAME=your_database -
Check network connectivity
# Test MongoDB connection
ping cluster.mongodb.net -
IP Whitelisting: Your IP address may not be whitelisted
- See MongoDB Setup for detailed IP whitelisting troubleshooting
- Quick check: Get your IP from ipinfo.io/ip and verify it's in MongoDB Atlas Network Access
-
Ensure MongoDB Atlas cluster is running
- Log in to MongoDB Atlas
- Check cluster status (should be green/active)
SSL/TLS Handshake Errors
Symptoms: "SSL: CERTIFICATE_VERIFY_FAILED" or "TLS handshake failed"
Solutions:
-
For Kubernetes/GKE deployments:
- Verify Docker image includes
ca-certificatesandopensslpackages - Ensure
certifiPython package is in requirements.txt - See MongoDB Setup for production deployment troubleshooting
- Verify Docker image includes
-
For local Docker:
- Usually handled automatically
- If issue persists, rebuild:
docker-compose build --no-cache
Authentication & Session Issues
Login Fails in Production (GKE/Kubernetes)
Symptoms: Login page loads correctly, but after entering credentials and clicking "Sign In", the page refreshes to blank with no error messages in browser console. Works locally but fails in cloud deployment.
Root Cause: Flask session cookies configured with SESSION_COOKIE_SECURE=True (required for HTTPS) but LoadBalancer/Ingress serving traffic over HTTP.
Solutions:
-
Temporary Fix (HTTP-only deployment):
- Set environment variable in
deployment.yml:env:
- name: SESSION_COOKIE_SECURE
value: "false" - Redeploy application
- Warning: This disables secure cookie flag. Only use for testing or non-production environments.
- Set environment variable in
-
Production Fix (Recommended):
- Configure HTTPS/TLS for your LoadBalancer or Ingress:
# Example Ingress with TLS
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: smartrunning-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
tls:
- hosts:
- your-domain.com
secretName: smartrunning-tls - Set
SESSION_COOKIE_SECURE=truein deployment configuration - Verify browser DevTools > Application > Cookies shows
Secureflag
- Configure HTTPS/TLS for your LoadBalancer or Ingress:
-
CORS Configuration:
- Ensure CORS is configured with credentials support (already implemented in
app/__init__.py):CORS(app, supports_credentials=True, resources={
r"/*": {"origins": "*", "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"]}
})
- Ensure CORS is configured with credentials support (already implemented in
Related Files:
app/config.py- Session cookie configuration (line 38)deployment.yml- Environment variables for Kubernetes deploymentapp/__init__.py- CORS configuration (line 59)
Verification:
- Check browser DevTools > Network >
/auth/loginresponse - Verify
Set-Cookieheader is present in response - Check
Application > Cookiesto see if session cookie is stored - If cookie has
Secureflag but site uses HTTP, login will fail silently
Session Expires Too Quickly
Symptoms: User is logged out after short period of inactivity
Solutions:
-
Increase session timeout in
.envordeployment.yml:env:
- name: SESSION_TIMEOUT_HOURS
value: "24" # Default is 8 hours -
Enable "Remember Me" checkbox on login page for 30-day persistent sessions
CORS Errors During Login
Symptoms: Browser console shows "CORS policy: No 'Access-Control-Allow-Origin' header"
Solutions:
- Verify CORS is enabled in
app/__init__.pywithsupports_credentials=True - Check that frontend and backend are using the same protocol (both HTTP or both HTTPS)
- If using custom domain, update CORS origins list to include your domain
Docker Issues
Container Won't Start
Symptoms: docker compose up fails or containers exit immediately
Solutions:
-
Clear existing containers and volumes
docker-compose down -v -
Rebuild containers without cache
docker-compose build --no-cache
docker-compose up -
Check Docker logs for specific errors
docker-compose logs -f web -
Verify Docker Desktop is running and has sufficient resources
- Recommended: 4GB RAM minimum, 2 CPUs
Port Already in Use
Symptoms: "Error starting userland proxy: Bind for 0.0.0.0:[port] failed: port is already allocated"
Solutions:
-
Find and kill process using the configured port
# On macOS/Linux
lsof -ti:[port] | xargs kill -9
# On Windows
netstat -ano | findstr :[port]
taskkill /PID [PID] /F -
Change port in
docker-compose.ymlif neededports:
- "[external_port]:5000" # Use different external port
File Upload Issues
Understanding Upload Workflow (Important!)
How It Works:
- Uploads are fully asynchronous - files are saved and processing happens in the background
- Upload completes in less than 1 second, then you see: "Files uploaded successfully. Processing in background..."
- No need to wait - you can navigate away or close the browser
- Processing continues in background: unzip, convert, analyze, update history
- Check the background jobs banner (top of page) for processing status
- New sessions appear automatically once processing completes (refresh page if needed)
What to Expect:
- Upload FIT/ZIP file(s)
- See immediate confirmation message
- Background jobs banner appears showing processing status
- Banner disappears when complete (usually 30 seconds to few minutes depending on file size)
- Refresh page to see new sessions in calendar/list
Common Misunderstanding:
- "Upload says complete but I don't see sessions", Processing still running in background, wait for banner to disappear
- "Where's the progress bar?", No progress bar needed, background jobs banner shows status
- "Is it stuck?", No, processing continues even if you navigate away or refresh
File Too Large
Symptoms: Upload fails with "413 Payload Too Large" or "File exceeds maximum size"
Solutions:
-
Check file size (default limit: 16MB)
# Check file size
ls -lh yourfile.fit -
Increase limit in
.envif neededMAX_CONTENT_LENGTH=33554432 # 32MB in bytes -
Restart application after changing
.env
Invalid File Format
Symptoms: Upload succeeds but processing fails, error logs show "Invalid FIT file"
Solutions:
-
Verify file format
- Accepted:
.fitfiles or.ziparchives containing.fitfiles - File must be a valid Garmin FIT file
- Accepted:
-
Check file isn't corrupted
- Try uploading a different FIT file
- Re-export from Garmin Connect
-
Check file encoding
- FIT files should be binary, not text
- File size should be > 0 bytes
Upload Directory Permissions
Symptoms: "Permission denied" errors when uploading files
Solutions:
-
For Docker: Check volume permissions in
docker-compose.ymlvolumes:
- ./data/uploads:/app/data/uploads -
For local development: Ensure upload directory exists and is writable
mkdir -p data/uploads
chmod 755 data/uploads
Session Processing Issues
Background Job Stuck
Symptoms: FIT file uploaded but never appears in sessions list
Solutions:
-
Check background job status
- View background jobs in admin dashboard at
/admin - Look for jobs with status "failed" or "pending"
- View background jobs in admin dashboard at
-
Check application logs for processing errors
docker-compose logs -f web | grep "ERROR" -
Restart application to reset job queue
docker-compose restart
Statistics Not Calculated
Symptoms: Session appears but has no statistics (HR zones, pace, etc.)
Solutions:
-
Verify FIT file contains required data
- Must have heart rate data for HR zone calculations
- Must have GPS/distance data for pace calculations
-
Check if Critical Speed is calculated for runner
- Required for rTSS calculation
- Navigate to runner profile and verify CS values exist
-
Manually trigger statistics recalculation
- Delete and re-upload the FIT file
- Or use admin tools to reprocess session
Training Plan Issues
Plan Generation Fails
Symptoms: "Failed to generate training plan" error
Solutions:
-
Verify runner has required data
- Personal best times for tracked distances
- Performance metrics calculated
- Heart rate zones configured
-
Check training plan schema is valid
- View in admin dashboard at
/admin - Ensure schema has at least one block with workouts
- View in admin dashboard at
-
Verify target date is in the future
- Marathon date must be later than today
Plan Days Not Displaying
Symptoms: Training plan created but calendar is empty
Solutions:
-
Check trainingplan collection in database
// In MongoDB, verify documents exist:
db.trainingplan.find({ trainingplanID: "your-plan-id" }).count() -
Verify browser console for JavaScript errors
- Open DevTools (F12)
- Check Console tab for errors
-
Clear browser cache and reload
# Hard refresh: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)
Performance Issues
Slow Session Loading
Symptoms: Sessions list takes long time to load
Solutions:
-
Large dataset: If runner has 500+ sessions, loading time increases
- This is expected behavior for large datasets
- The system processes all sessions for display
-
Database indexes: Verify indexes are in place per Database Schema
// Performance indexes:
db.sessionsFIT.createIndex({ runner_id: 1, uploaded_at: -1 })
db.sessionStatistics.createIndex({ runner_id: 1, processed_timestamp: -1 })
Slow Chart Rendering
Symptoms: Training load charts render slowly or freeze browser
Solutions:
-
Reduce date range
- Load smaller time periods (e.g., last 3 months instead of all time)
-
Check runnerHistory collection size
db.runnerHistory.find({ runner_id: ObjectId(...) }).count() -
For large datasets, reduce the display window
- Use date range filters to limit data points
Development Issues
Python Import Errors
Symptoms: ModuleNotFoundError when running locally
Solutions:
-
Ensure virtual environment is activated
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows -
Install dependencies
pip install -r requirements.txt -
Verify Python version
python --version # Should be 3.11-3.13
MongoDB Connection Works Locally But Not in Kubernetes
Symptoms: Application runs fine locally but fails when deployed to GKE
Solutions:
-
Most common cause: IP whitelisting
- See MongoDB Setup for detailed Kubernetes network troubleshooting
- GKE egress IP is different from LoadBalancer IP
-
Check environment variables in Kubernetes
kubectl get configmap
kubectl describe configmap <name>
Still Having Issues?
If your problem isn't listed here:
-
Check application logs:
# Docker
docker-compose logs -f web
# Kubernetes
kubectl logs deployment/smartrunning-localapp --tail=50 -
Check MongoDB logs in MongoDB Atlas UI
-
Verify environment configuration:
# Ensure all required variables are set
cat .env | grep -v '^#' | grep -v '^$' -
Search for similar issues in project documentation:
- Platform Overview - General setup
- Architecture - System design
- Database Schema - Database structure
- MongoDB Setup - MongoDB-specific issues
-
Contact support with:
- Detailed error message
- Steps to reproduce
- Environment (local Docker / Kubernetes / local Python)
- Relevant log excerpts