Skip to main content

Troubleshooting

Solutions to common problems and debugging techniques to get you back on track quickly.

Authentication Issues

Issue: “API key is invalid”

Symptoms:
Solutions:
  1. Verify API Key is Correct
  2. Check API Key Format
    • API keys are typically 32-64 characters
    • Should be alphanumeric
    • Don’t add quotes or extra spaces
  3. Verify API Key is Active
    • Go to CocoBase Dashboard
    • Check if the API key is enabled
    • Check expiration date
  4. Use Environment Variables

Issue: “User session expired”

Symptoms:
Solutions:
  1. Implement Token Refresh
  2. Check Token Storage
  3. Clear Cache and Retry

Issue: “Email already registered”

Symptoms:
Solutions:
  1. Use Different Email
  2. Implement Password Reset Flow Instead of creating a new account, direct users to password reset.

Connection Problems

Issue: “Network timeout”

Symptoms:
Solutions:
  1. Check Internet Connection
  2. Implement Retry Logic
  3. Increase Timeout (if needed)

Issue: “Certificate verification failed”

Symptoms:
Solutions:
  1. Ensure Using HTTPS
  2. Check Device Date/Time
    • SSL certificates are time-sensitive
    • Ensure device date/time is correct
  3. Update Dependencies

Query Issues

Issue: “No results when expecting data”

Common Causes & Solutions:
  1. Field Name Typo
  2. Case Sensitivity Field names are case-sensitive! Match the exact case from your database schema.
  3. Operator Missing
  4. 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 in fromJson() method
Fix Strategy:

Issue: “NoSuchMethodError: The method ‘fromJson’ was called on null”

Cause: Converter not registered

Issue: “null value error when accessing optional field”

Cause: Not handling null values

Real-Time Connection Problems

Issue: “WebSocket connection fails”

Solutions:
  1. Verify Collection Exists
  2. Check WebSocket is Enabled Most BaaS platforms enable WebSocket by default. Verify in your project settings.
  3. Use Correct Filters

Issue: “Real-time updates stopped”

Solutions:
  1. Reconnect on Disconnect
  2. Check Network State

File Upload Errors

Issue: “File upload fails”

Common Causes:
  1. File Too Large
  2. Invalid File Type
  3. Network Timeout

Performance Issues

Issue: “App is slow when loading many documents”

Solutions:
  1. Use Pagination
  2. Select Only Needed Fields
  3. Use Indexes

Issue: “Memory usage increases over time”

Solutions:
  1. Clear Collections
  2. Dispose Resources

Cloud Functions Issues

Issue: “Function execution timeout”

Causes:
  • Heavy computation
  • Database query taking too long
  • External API call delay
Solutions:
  1. Optimize Database Queries
  2. Use Indexes
  3. Implement Caching

Issue: “Function returns unexpected errors”

Debug Steps:
  1. Enable Logging
  2. Validate Input
  3. Test Locally Create a test script with sample data to debug your function logic.

Debugging Tips

Enable Debug Logging

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
See Query Optimization for solutions.

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 use db.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:
  1. Registered the converter: CocobaseConverters.register<Book>(Book.fromJson)
  2. Used the correct type parameter: db.listDocuments<Book>("books")
  3. Defined fromJson() factory method correctly

Getting Help

Resources

  1. Documentation
  2. Community
  3. Contact Support
    • Email: support@cocobase.cc
    • Dashboard: Help button in top-right corner
    • Live Chat: Available during business hours

Reporting Issues

When reporting a bug, include:

Before Asking for Help

  1. Check this troubleshooting guide
  2. Review the documentation
  3. Search existing GitHub issues
  4. Try a minimal reproduction
  5. Check your API key and network connection

Error Code Reference


Next Steps