๐ง Troubleshooting Guide¶
๐ฏ Overview¶
This comprehensive troubleshooting guide covers common issues encountered when working with the Continuum API Gateway, including authentication problems, permission errors, collection management issues, and performance concerns.
๐ Authentication Issues¶
โ Error 401: Unauthorized¶
Error Message:
๐ Possible Causes¶
- API Key is Missing or Malformed
- API Key Has Expired
- APP_KEY Changed After Key Generation
- Wrong Application Specified
- API Key Revoked
โ Solutions¶
Check Header Format:
# Correct format
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# Common mistakes:
# โ Missing "Bearer " prefix
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# โ Extra spaces
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# โ Wrong header name
Auth: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Verify API Key Validity:
# List your API keys to check expiration
GET /api/apiKeys:list
X-App: main
Authorization: Bearer {admin-api-key}
# Look for "expiresAt" field
Generate New API Key:
POST /api/apiKeys:create
X-App: main
Authorization: Bearer {user-token}
Content-Type: application/json
{
"role": {
"name": "admin"
},
"expiresIn": "30d"
}
Check APP_KEY Configuration:
# Ensure APP_KEY is set in environment
echo $APP_KEY
# If empty or changed, all existing keys are invalid
# Set it permanently in .env
APP_KEY=your-persistent-64-character-secret-key
Verify Correct Application:
# List available applications
GET /api/applications:list
X-App: main
# Ensure X-App header matches key's application
โ Error: "API key not valid for application"¶
Error Message:
๐ Cause¶
Using an API key from one application to access another application.
โ Solution¶
Create application-specific API keys:
# Create key for specific application
POST /api/apiKeys:create
X-App: marketing-platform
Authorization: Bearer {user-token-for-that-app}
{
"role": {"name": "admin"},
"expiresIn": "30d"
}
# Use with correct X-App header
GET /api/campaigns:list
X-App: marketing-platform
Authorization: Bearer {new-app-specific-key}
๐ก๏ธ Permission Issues¶
โ Error 403: No Permissions¶
Error Message:
๐ Possible Causes¶
- Role Lacks Required Permissions
- Filter Conditions Deny Access
- Field Restrictions Prevent Action
- Public Access Not Configured
โ Solutions¶
Check Role Permissions:
# Get role details with permissions
GET /api/roles:get?filterByTk=editor&appends=permissions
X-App: main
Authorization: Bearer {admin-api-key}
# Look for the specific resource and action
Check Filter Restrictions:
# If you can list some records but not all:
# Check if filters are limiting access
# Example: Can only see own articles
{
"filter": {
"authorId": "{{ ctx.state.currentUser.id }}"
}
}
# Solution: Use appropriate user context or request admin access
Create Key with Higher Privileges:
# If current key has limited role
POST /api/apiKeys:create
X-App: main
{
"role": {"name": "admin"}, # Higher privilege role
"expiresIn": "7d"
}
Configure Public Access (if appropriate):
โ Error: "Field access denied"¶
Error Message:
๐ Cause¶
Role's permissions don't include the requested field.
โ Solution¶
Check Field Restrictions:
# View permissions with field configurations
GET /api/roles:get?filterByTk={role-name}&appends=permissions
X-App: main
# Look for "fields" or "except" in permissions
Request Allowed Fields Only:
# Good: Request only allowed fields
GET /api/users:list?fields=id,name,email
X-App: main
# Bad: Requesting restricted fields
GET /api/users:list?fields=id,name,password
X-App: main
๐ฆ Collection Issues¶
โ Error 404: Collection Not Found¶
Error Message:
๐ Possible Causes¶
- Collection Name Typo
- Collection Not Created Yet
- Wrong Application
- Collection Was Deleted
โ Solutions¶
List Available Collections:
Check Collection Name:
# Collection names are case-sensitive
# โ
Correct
GET /api/blog_posts:list
# โ Wrong
GET /api/Blog_Posts:list
GET /api/blogPosts:list
Create Collection if Missing:
POST /api/collections:create
X-App: main
{
"name": "articles",
"title": "Articles",
"fields": [...]
}
โ Error: "Field does not exist"¶
Error Message:
{
"error": "Bad Request",
"message": "Field 'publishDate' does not exist in collection 'articles'"
}
๐ Cause¶
Trying to access, filter, or sort by a field that doesn't exist.
โ Solutions¶
List Collection Fields:
Check Field Name:
# Common mistake: wrong field name
# โ publishDate
# โ
publishedAt
GET /api/articles:list?sort=-publishedAt
Add Missing Field:
POST /api/fields:create
X-App: main
{
"collectionName": "articles",
"name": "publishDate",
"type": "date"
}
โ Error: "Cannot modify system collection"¶
Error Message:
๐ Cause¶
Attempting to modify a built-in system collection.
โ Solution¶
System collections (users, roles, permissions) have restricted modification:
- โ CAN: Add custom fields
- โ CANNOT: Delete collection or modify core fields
# โ
Allowed: Add custom field
POST /api/fields:create
{
"collectionName": "users",
"name": "department",
"type": "string"
}
# โ Not allowed: Delete system field
POST /api/fields:destroy
{
"collectionName": "users",
"name": "email" # Core field
}
๐ CRUD Operation Issues¶
โ Error: "Validation failed"¶
Error Message:
{
"error": "Validation Error",
"message": "Validation failed",
"details": {
"title": "Title is required",
"email": "Email must be valid"
}
}
๐ Cause¶
Data doesn't meet validation requirements.
โ Solution¶
Check Required Fields:
# Get collection schema to see required fields
GET /api/collections:get?filterByTk=articles&appends=fields
X-App: main
# Include all required fields in request
POST /api/articles:create
{
"title": "Required field", # โ
Included
"content": "..."
}
Validate Data Types:
# โ Wrong type
{
"price": "nine ninety-nine" # Should be number
}
# โ
Correct type
{
"price": 9.99
}
โ Error: "Unique constraint violation"¶
Error Message:
๐ Cause¶
Trying to create/update with a value that already exists for a unique field.
โ Solutions¶
Check Existing Records:
Update Instead of Create:
Use Different Value:
โ Error: "Foreign key constraint failed"¶
Error Message:
๐ Cause¶
Referenced record doesn't exist (e.g., author with ID 999 doesn't exist).
โ Solutions¶
Verify Referenced Record Exists:
# Check if user exists
GET /api/users:get?filterByTk=999
X-App: main
# If not, use valid user ID
POST /api/articles:create
{
"title": "Article",
"authorId": 5 # Existing user ID
}
Create Referenced Record First:
# Create user first
POST /api/users:create
{
"name": "New Author",
"email": "author@example.com"
}
# Response: {"data": {"id": 10, ...}}
# Then create article
POST /api/articles:create
{
"title": "Article",
"authorId": 10
}
๐ Multi-App Issues¶
โ Error: "Application not found"¶
Error Message:
๐ Possible Causes¶
- Application Name Typo
- Application Doesn't Exist
- Application Not Started
โ Solutions¶
List Available Applications:
Check Application Name:
# Application names are case-sensitive and exact
X-App: marketing-platform # โ
Correct
X-App: Marketing-Platform # โ Wrong case
X-App: marketing platform # โ Space
Create Application if Missing:
POST /api/applications:create
X-App: main
{
"name": "marketing-platform",
"displayName": "Marketing Platform",
"options": {
"autoStart": true
}
}
โ Error: "Application initialization failed"¶
Error Message:
๐ Possible Causes¶
- Database Connection Error
- Plugin Loading Failure
- Configuration Issue
- Insufficient Resources
โ Solutions¶
Check Application Status:
Review Server Logs:
Restart Application:
Check Database Configuration:
โก Performance Issues¶
โ Slow Query Response¶
Symptom: API requests taking > 1 second
๐ Possible Causes¶
- Missing Indexes
- Fetching Too Much Data
- N+1 Query Problem
- Complex Filters
- No Caching
โ Solutions¶
Add Indexes:
# Identify slow queries from logs
# Add indexes to frequently filtered/sorted fields
# In database:
CREATE INDEX idx_articles_status ON articles(status);
CREATE INDEX idx_articles_published_at ON articles(published_at);
Use Pagination:
# โ Bad: Fetch all records
GET /api/articles:list?paginate=false
# โ
Good: Paginate
GET /api/articles:list?page=1&pageSize=20
Select Only Needed Fields:
# โ Bad: All fields
GET /api/articles:list
# โ
Good: Specific fields
GET /api/articles:list?fields=id,title,createdAt
Optimize Relationship Loading:
# โ Bad: Loading too many relations
GET /api/articles:list?appends=author,comments,tags,category,relatedPosts
# โ
Good: Only needed relations
GET /api/articles:list?appends=author
Use Efficient Filters:
# โ Slow: LIKE with leading wildcard
GET /api/articles:list?filter={"title":{"$like":"%search%"}}
# โ
Faster: Exact match or indexed field
GET /api/articles:list?filter={"status":"published"}
๐ง General Debugging¶
๐ Enable Debug Logging¶
# Set environment variable
DEBUG=api:*
# Restart server
# Check logs for detailed request/response info
๐ Test with cURL¶
Isolate issues by testing with cURL:
# Full verbose output
curl -v \
-H "X-App: main" \
-H "Authorization: Bearer {api-key}" \
https://your-domain.com/api/articles:list
# Specific checks:
# - HTTP status code
# - Response headers
# - Response body
# - Request headers sent
๐งช Test in Different Environments¶
# Development
X-App: dev-environment
# Staging
X-App: staging-environment
# Production
X-App: main
# If works in one but not another, it's environment-specific
๐ Check API Documentation¶
# Access Swagger UI
https://your-domain.com/admin/settings/api-doc/documentation
# Verify:
# - Endpoint exists
# - Request format
# - Required parameters
# - Expected responses
๐ Getting Help¶
๐ Before Requesting Support¶
Gather the following information:
- Error Message: Full error response
- Request Details:
- Application Context: Which app, environment
- API Key Role: What permissions the key has
- Recent Changes: Schema changes, permission updates
- Server Logs: Relevant log entries
๐ Diagnostic Endpoints¶
# System health
GET /api/health
X-App: main
# Current user context
GET /api/auth:check
X-App: main
Authorization: Bearer {api-key}
# Application info
GET /api/applications:get?filterByTk=main
X-App: main
๐ Related Documentation¶
- API Gateway: Overall architecture
- Authentication: API key management
- Permissions: Access control configuration
- Best Practices: Optimization and security guidelines
Note: Most issues can be resolved by checking authentication, permissions, and request format. When in doubt, consult the Swagger documentation and verify with admin credentials.