Troubleshooting
Solutions to common problems and debugging techniques to get you back on track quickly.Authentication Issues
Issue: “API key is invalid”
Symptoms:-
Verify API Key is Correct
- Flutter
- JavaScript
- Python
- Go
-
Check API Key Format
- API keys are typically 32-64 characters
- Should be alphanumeric
- Don’t add quotes or extra spaces
-
Verify API Key is Active
- Go to CocoBase Dashboard
- Check if the API key is enabled
- Check expiration date
-
Use Environment Variables
Issue: “User session expired”
Symptoms:-
Implement Token Refresh
-
Check Token Storage
-
Clear Cache and Retry
Issue: “Email already registered”
Symptoms:-
Use Different Email
- Implement Password Reset Flow Instead of creating a new account, direct users to password reset.
Connection Problems
Issue: “Network timeout”
Symptoms:-
Check Internet Connection
-
Implement Retry Logic
-
Increase Timeout (if needed)
Issue: “Certificate verification failed”
Symptoms:-
Ensure Using HTTPS
-
Check Device Date/Time
- SSL certificates are time-sensitive
- Ensure device date/time is correct
-
Update Dependencies
Query Issues
Issue: “No results when expecting data”
Common Causes & Solutions:-
Field Name Typo
- Case Sensitivity Field names are case-sensitive! Match the exact case from your database schema.
-
Operator Missing
-
Wrong Data Type
Issue: “QueryBuilder not building correct query”
Debug with.build():
Issue: “Pagination not working”
Common Mistakes:Type Conversion Errors
Issue: “type ‘_InternalLinkedHashMap<String, dynamic>’ is not a subtype”
Cause: Type mismatch infromJson() method
Issue: “NoSuchMethodError: The method ‘fromJson’ was called on null”
Cause: Converter not registeredIssue: “null value error when accessing optional field”
Cause: Not handling null valuesReal-Time Connection Problems
Issue: “WebSocket connection fails”
Solutions:-
Verify Collection Exists
- Check WebSocket is Enabled Most BaaS platforms enable WebSocket by default. Verify in your project settings.
-
Use Correct Filters
Issue: “Real-time updates stopped”
Solutions:-
Reconnect on Disconnect
-
Check Network State
File Upload Errors
Issue: “File upload fails”
Common Causes:-
File Too Large
-
Invalid File Type
-
Network Timeout
Performance Issues
Issue: “App is slow when loading many documents”
Solutions:-
Use Pagination
-
Select Only Needed Fields
-
Use Indexes
Issue: “Memory usage increases over time”
Solutions:-
Clear Collections
-
Dispose Resources
Cloud Functions Issues
Issue: “Function execution timeout”
Causes:- Heavy computation
- Database query taking too long
- External API call delay
-
Optimize Database Queries
-
Use Indexes
-
Implement Caching
Issue: “Function returns unexpected errors”
Debug Steps:-
Enable Logging
-
Validate Input
- Test Locally Create a test script with sample data to debug your function logic.
Debugging Tips
Enable Debug Logging
- Flutter
- JavaScript
- Go
Print Document Details
Check Query String
Test in Isolation
Create minimal reproduction cases:Common Error Messages
”Collection not found”
Solution: Create the collection first or check spelling.”Invalid filter operator”
Solution: Check operator syntax.”Document not found”
Solution: Verify document ID exists.”Validation failed”
Solution: Check required fields and data types.FAQ
Q: How do I reset my API key?
A: Go to your CocoBase Dashboard → Settings → API Keys → Generate New Key. Update your application with the new key before revoking the old one.Q: Why are my queries slow?
A: Common causes:- Missing indexes on queried fields
- Fetching too many documents (use pagination)
- Populating too many relationships
- Not using query operators efficiently
Q: How do I handle rate limiting?
A: Implement retry logic with exponential backoff. See Rate Limiting for examples.Q: Can I use raw SQL queries?
A: In cloud functions, you can usedb.execute_raw_query() but be careful with SQL injection. Always use parameterized queries.
Q: How do I backup my data?
A: Use the export functionality or create a cloud function that periodically exports data to cloud storage.Q: Why isn’t my converter working?
A: Make sure you:- Registered the converter:
CocobaseConverters.register<Book>(Book.fromJson) - Used the correct type parameter:
db.listDocuments<Book>("books") - Defined
fromJson()factory method correctly
Getting Help
Resources
- Documentation
-
Community
- GitHub Issues: cocobase/issues
- Stack Overflow: Tag questions with
cocobase - Discord: Join our community
-
Contact Support
- Email: [email protected]
- Dashboard: Help button in top-right corner
- Live Chat: Available during business hours
Reporting Issues
When reporting a bug, include:Before Asking for Help
- Check this troubleshooting guide
- Review the documentation
- Search existing GitHub issues
- Try a minimal reproduction
- Check your API key and network connection
Error Code Reference
| Code | Meaning | Common Cause |
|---|---|---|
| 400 | Bad Request | Invalid data format, missing required fields |
| 401 | Unauthorized | Invalid API key, expired session |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource doesn’t exist |
| 409 | Conflict | Duplicate entry (e.g., email already exists) |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server-side error |
| 502 | Bad Gateway | Temporary server issue |
| 503 | Service Unavailable | Server maintenance or overload |
Next Steps
- Best Practices - Optimize your code
- Examples - Learn from real-world code
- Cloud Functions - Build serverless functions
- Advanced Features - Master advanced techniques
