Troubleshooting Guide
Last Updated: 2026-01-30
This guide helps diagnose and resolve common issues across the Bayit+ platform (backend, web, mobile, tvOS).
Quick Diagnostic Checklist
Before diving into specific issues, run through this checklist:
- [ ] Server is running - Backend on port 8000
- [ ] Database is connected - MongoDB Atlas reachable
- [ ] Environment variables set - Check
.envfile - [ ] Secrets configured - Google Cloud Secret Manager
- [ ] Dependencies installed -
poetry install/npm install - [ ] Correct Node/Python version - Node 18+, Python 3.11
- [ ] Firewall allows connections - Check network rules
- [ ] Check logs - Backend logs, browser console, device logs
Backend Issues
Issue: Server Won't Start
Symptoms:
poetry run uvicorn app.main:app --reloadfails- Error: "Address already in use"
- Error: "Cannot connect to MongoDB"
Causes & Solutions:
1. Port 8000 already in use:
# Find process using port 8000
lsof -i :8000
# Kill the process
kill -9 <PID>
# Or use different port (not recommended)
uvicorn app.main:app --port 80012. MongoDB connection failure:
# Check MongoDB URI in .env
cat backend/.env | grep MONGODB_URI
# Test connection
mongosh "mongodb+srv://..." --eval "db.stats()"
# Check network access in MongoDB Atlas
# https://cloud.mongodb.com → Network Access3. Missing dependencies:
cd backend
poetry install
poetry show # Verify packages installedIssue: Import Errors
Symptoms:
ModuleNotFoundError: No module named 'app'ImportError: cannot import name 'X' from 'Y'
Solutions:
1. Python path issue:
# Run from project root
cd /path/to/bayit-plus
poetry run uvicorn app.main:app --reload
# Not from backend/ directory2. Circular imports:
Check for circular dependencies:
# ❌ BAD - Circular
# file_a.py
from file_b import X
# file_b.py
from file_a import Y
# ✅ GOOD - Move shared code to utils
# utils.py
class Shared: pass
# file_a.py
from utils import Shared
# file_b.py
from utils import Shared3. Missing __init__.py:
Ensure all directories have __init__.py:
find backend/app -type d -exec touch {}/__init__.py \;Issue: Database Queries Failing
Symptoms:
- Error: "Collection was not initialized"
- Error: "Document not found"
- Slow queries
Solutions:
1. Collections not initialized:
# Ensure init_beanie() called in startup
from app.core.database import connect_to_mongo
await connect_to_mongo() # Initializes all collections2. Index missing:
# Check indexes
mongosh "mongodb+srv://..." --eval "db.content.getIndexes()"
# Create missing index
mongosh "mongodb+srv://..." --eval 'db.content.createIndex({title: "text"})'3. Query optimization:
# ❌ SLOW - No index
await Content.find(Content.title == "Movie").to_list()
# ✅ FAST - Use indexed field
await Content.find(Content.section_ids.in_(["movies"])).to_list()
# ✅ FASTER - Limit results
await Content.find(Content.section_ids.in_(["movies"])).limit(20).to_list()Issue: Authentication Failures
Symptoms:
- 401 Unauthorized errors
- Token expired messages
- Login fails
Solutions:
1. Check JWT configuration:
# Verify SECRET_KEY set
echo $SECRET_KEY
# Should output a long random string
# Check token expiration
cat backend/.env | grep JWT_EXPIRY_HOURS2. Token format:
# Token should be: Bearer <token>
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# ❌ WRONG
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...3. Firebase token issues:
# Check Firebase credentials
cat backend/.env | grep FIREBASE_
# Regenerate Firebase service account key if needed
# https://console.firebase.google.com → Project Settings → Service AccountsIssue: API Rate Limiting
Symptoms:
- 429 Too Many Requests
- "Rate limit exceeded" errors
Solutions:
1. Check rate limit tier:
# Check user's rate limit
from app.models.user import User
user = await User.find_one(User.email == "user@example.com")
print(user.role) # free/beta/premium/admin2. Implement exponential backoff:
import asyncio
async def retry_with_backoff(fn, max_retries=3):
for i in range(max_retries):
try:
return await fn()
except HTTPException as e:
if e.status_code == 429 and i < max_retries - 1:
wait = 2 ** i # 1s, 2s, 4s
await asyncio.sleep(wait)
else:
raiseFrontend Issues (Web)
Issue: API Calls Failing (CORS)
Symptoms:
- Console error: "CORS policy blocked"
- Network tab shows preflight OPTIONS failing
Solutions:
1. Check Vite proxy configuration:
// vite.config.js
export default defineConfig({
server: {
proxy: {
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
},
},
},
});2. Verify backend CORS settings:
# app/main.py
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)3. Check request headers:
// Ensure Authorization header included
fetch('/api/v1/content', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
});Issue: Components Not Rendering
Symptoms:
- Blank screen
- "Cannot read property 'X' of undefined"
- React errors in console
Solutions:
1. Check for null/undefined data:
// ❌ CRASH if data is undefined
const title = data.content.title;
// ✅ SAFE - Optional chaining
const title = data?.content?.title ?? 'Default Title';2. Verify API response format:
// Check API response structure
console.log('API Response:', data);
// Ensure success field exists
if (data.success) {
setContent(data.data);
}3. Check React DevTools:
Open React DevTools → Components → Find component → Check props and state
Issue: Zustand Store Not Updating
Symptoms:
- State changes don't trigger re-renders
- UI doesn't reflect latest data
Solutions:
1. Check store definition:
// ✅ CORRECT - Returns new object
set(state => ({ ...state, credits: newCredits }))
// ❌ WRONG - Mutates state directly
set(state => { state.credits = newCredits; return state; })2. Use devtools:
import { devtools } from 'zustand/middleware';
export const useStore = create(
devtools((set) => ({
// ... store definition
}))
);
// Open Redux DevTools to inspect store changes3. Subscribe to changes:
// Debug store updates
useStore.subscribe((state) => {
console.log('Store updated:', state);
});Mobile Issues (React Native)
Issue: Metro Bundler Fails
Symptoms:
- "Unable to resolve module"
- "Module not found"
- Build errors
Solutions:
1. Clear caches:
cd mobile-app
rm -rf node_modules
rm package-lock.json
npm install
# Clear Metro cache
npm start -- --reset-cache
# Clear iOS build cache
cd ios
rm -rf Pods Podfile.lock
pod install
cd ..2. Check module resolution:
// metro.config.js
module.exports = {
resolver: {
extraNodeModules: {
'@bayit/glass': path.resolve(__dirname, '../shared/components'),
},
},
};3. Restart development server:
# Kill Metro
lsof -ti:8081 | xargs kill -9
# Restart
npm startIssue: iOS Build Fails
Symptoms:
- Xcode build errors
- CocoaPods errors
- Linker errors
Solutions:
1. Reinstall pods:
cd mobile-app/ios
rm -rf Pods Podfile.lock
pod install --repo-update
cd ..2. Clean Xcode:
# Clean derived data
rm -rf ~/Library/Developer/Xcode/DerivedData
# Clean build
xcodebuild clean -workspace BayitPlus.xcworkspace -scheme BayitPlus3. Check iOS version:
# Ensure deployment target matches
# ios/Podfile
platform :ios, '16.0'
# BayitPlus.xcodeproj → Build Settings → iOS Deployment Target
# Should be 16.0 or higherIssue: Android Build Fails
Symptoms:
- Gradle build errors
- "Could not find" dependency errors
Solutions:
1. Clean Gradle:
cd mobile-app/android
./gradlew clean
cd ..2. Fix dependency issues:
cd mobile-app/android
./gradlew app:dependencies
# Check for version conflicts3. Increase memory:
# android/gradle.properties
org.gradle.jvmargs=-Xmx4096mtvOS Issues
Issue: Focus Navigation Not Working
Symptoms:
- Cannot navigate with Siri Remote
- Focus stuck on element
- No visual focus indicator
Solutions:
1. Verify focusable components:
// ✅ CORRECT - Focusable component
<Pressable focusable={true} onPress={handlePress}>
<Text>Button</Text>
</Pressable>
// ❌ WRONG - Not focusable
<View onPress={handlePress}>
<Text>Button</Text>
</View>2. Add focus styles:
const styles = StyleSheet.create({
button: {
backgroundColor: 'rgba(255,255,255,0.1)',
},
buttonFocused: {
backgroundColor: 'rgba(255,255,255,0.3)',
transform: [{ scale: 1.05 }],
},
});
<Pressable
style={({ focused }) => [
styles.button,
focused && styles.buttonFocused
]}
>3. Use TVFocusGuideView:
import { TVFocusGuideView } from 'react-native';
<TVFocusGuideView
autoFocus={true}
destinations={[buttonRef.current]}
>
<View>
{/* Content */}
</View>
</TVFocusGuideView>AI Features Issues
Issue: AI Search Not Working
Symptoms:
- "Insufficient credits" error
- No search results
- Slow responses
Solutions:
1. Check credit balance:
# Get user credits
curl -X GET "http://localhost:8000/api/v1/beta/credits/balance" \
-H "Authorization: Bearer TOKEN"2. Check API keys:
# Verify Claude/OpenAI API key
gcloud secrets versions access latest --secret="ANTHROPIC_API_KEY"3. Check rate limits:
# Increase timeout for AI requests
async with httpx.AsyncClient(timeout=60.0) as client:
response = await client.post(...)Issue: Voice Features Not Working
Symptoms:
- TTS not speaking
- STT not recognizing
- Audio playback fails
Solutions:
1. Check ElevenLabs API:
# Test ElevenLabs API
curl -X GET "https://api.elevenlabs.io/v1/voices" \
-H "xi-api-key: YOUR_KEY"2. Check browser permissions:
// Request microphone permission
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => console.log('Mic access granted'))
.catch(err => console.error('Mic access denied:', err));3. Check audio format:
// Ensure correct audio format for STT
const audioConfig = {
sampleRate: 16000,
channelCount: 1,
format: 'audio/wav',
};Performance Issues
Issue: Slow API Responses
Symptoms:
- Response time > 500ms
- Timeout errors
Solutions:
1. Check query performance:
# Add explain() to queries
query = Content.find(Content.title == "Movie")
explain = await query.motor_collection.explain()
print(explain['executionStats'])2. Add indexes:
# Create index for frequently queried field
mongosh "mongodb+srv://..." --eval 'db.content.createIndex({section_ids: 1})'3. Implement caching:
from functools import lru_cache
@lru_cache(maxsize=100)
async def get_content_cached(content_id: str):
return await Content.get(content_id)Issue: High Memory Usage
Symptoms:
- Backend OOM (Out of Memory)
- Slow performance
- Crashes
Solutions:
1. Limit query results:
# ❌ BAD - Loads all documents into memory
all_content = await Content.find_all().to_list()
# ✅ GOOD - Paginate
content = await Content.find().limit(100).to_list()2. Use streaming:
# Stream large results
async for content in Content.find():
process(content)3. Increase memory limits:
# Cloud Run
gcloud run services update bayit-backend-production \
--memory=4GiLogging & Debugging
Enable Debug Logging
Backend:
# Set log level
export LOG_LEVEL=DEBUG
# Or in .env
LOG_LEVEL=DEBUG
# Restart server
poetry run uvicorn app.main:app --reloadFrontend:
// Enable debug logs
localStorage.setItem('debug', 'bayit:*');
// View logs in consoleCheck Logs
Backend logs:
# Local
tail -f logs/backend.log
# Cloud Run
gcloud logging read "resource.type=cloud_run_revision AND \
resource.labels.service_name=bayit-backend-production" \
--limit=50 --format=jsonFrontend logs:
# Browser console (F12)
# Look for:
# - Network tab (API calls)
# - Console tab (errors)
# - Application tab (storage)Common Log Messages
| Log Message | Meaning | Action |
|---|---|---|
Connection refused | Backend not running | Start backend server |
Token expired | JWT expired | Refresh token or re-login |
Collection not initialized | Database setup failed | Check MongoDB connection |
Rate limit exceeded | Too many requests | Implement backoff |
Validation error | Invalid request | Check request format |
Getting Help
Before Asking for Help
- Check this guide - Common issues covered here
- Check logs - Error messages provide clues
- Search documentation - docs.bayitplus.com
- Check GitHub issues - Similar problems reported
- Try minimal reproduction - Isolate the issue
Information to Provide
When reporting issues, include:
- Platform - Web/iOS/Android/tvOS
- Environment - Production/Staging/Local
- Error message - Full error text
- Steps to reproduce - What you did before error
- Expected vs actual - What should happen vs what happened
- Logs - Backend logs, console logs
- Version - App version, Node version, Python version
- Request ID - From
X-Request-IDorX-Correlation-IDheader
Support Channels
- Email: support@bayitplus.com
- Community: community.bayitplus.com
- GitHub Issues: github.com/bayit-plus/issues
- Slack: #bayit-plus-support (internal)
Related Documents
Document Status: ✅ Complete Last Updated: 2026-01-30 Maintained by: Support Team Next Review: 2026-04-30