Documentation Index
Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt
Use this file to discover all available pages before exploring further.
Where to Find Logs
Before debugging any issue, know where to look.Local Development
When runningnpm run dev, all server logs appear in your terminal’s stdout/stderr. Next.js prints compilation errors, API route logs, and unhandled exceptions directly to the console.
Docker
Production (Structured Logging)
In production, KaireonAI outputs structured JSON logs via Winston. Control the verbosity with theLOG_LEVEL environment variable:
Correlating Logs with API Responses
Every API error response includes arecommendationId field. Use it to find the matching server-side log entry:
Startup Issues
These errors typically occur when starting the development server or deploying for the first time.The datasource property 'url' is no longer supported in schema files
The datasource property 'url' is no longer supported in schema files
Cause: KaireonAI uses Prisma 7, which moved the datasource URL out of The connection URL is defined in
schema.prisma and into prisma.config.ts.Fix: Open prisma/schema.prisma and ensure the datasource block only contains the provider — no url line:prisma.config.ts and reads from the DATABASE_URL environment variable.Cannot find module '@generated/prisma'
Cannot find module '@generated/prisma'
Cause: The Prisma client has not been generated yet. The generated client lives in This runs automatically on
platform/generated/prisma/ and is gitignored, so it must be created locally.Fix:npm install via the postinstall script, but you may need to run it manually after schema changes.P1001: Can't reach database server
P1001: Can't reach database server
Cause: The application cannot connect to PostgreSQL.Fix — checklist:
- Verify
DATABASE_URLis set in your.envfile - Ensure PostgreSQL is running (
pg_isreadyorpsqlto test) - Confirm the hostname, port, database name, and credentials in the URL are correct
- If using Docker, make sure the container is up and the port is mapped
NEXTAUTH_SECRET is not set
NEXTAUTH_SECRET is not set
Cause: The authentication system requires a secret key for signing session tokens.Fix: Add
NEXTAUTH_SECRET to your .env file:Port 3000 already in use
Port 3000 already in use
Cause: Another process is already listening on port 3000.Fix: Either kill the existing process or start on a different port:
AI Chat not working — 'LLM provider not configured'
AI Chat not working — 'LLM provider not configured'
Cause: The AI assistant requires an LLM provider to be configured before it can respond.Fix: Go to Settings > AI Configuration and configure your preferred provider:
- Google Gemini — Free tier available, good starting point
- OpenAI — GPT-4o and GPT-4o-mini
- Anthropic — Claude models
- Ollama — Self-hosted open-source models (no API key needed)
Docker build fails with SIGKILL (exit code 137)
Docker build fails with SIGKILL (exit code 137)
Cause: The Docker build process ran out of memory. Next.js builds and Prisma generation are memory-intensive.Fix: Increase Docker Desktop memory allocation to at least 8 GB:If you are on a CI server, ensure the build runner has at least 8 GB of RAM available.
- Open Docker Desktop > Settings > Resources
- Set Memory to
8.00 GB(or higher) - Click Apply & Restart
- Retry the build:
CSRF errors on API calls (403 Forbidden)
CSRF errors on API calls (403 Forbidden)
Cause: KaireonAI enforces CSRF protection on state-changing requests. Requests from API clients (not the browser UI) must include a specific header.Fix: Add the This header signals that the request is intentional and not a cross-site forgery attempt.
X-Requested-With header to all POST, PUT, PATCH, and DELETE requests:Starbucks sample dataset load fails
Starbucks sample dataset load fails
Cause: The dataset loader creates multiple tables and inserts several thousand rows. Failures are typically caused by database connectivity issues or insufficient disk space.Fix — checklist:
- Verify the database connection is working:
psql "$DATABASE_URL" -c "SELECT 1" - Check available disk space on the database server (the dataset requires ~50 MB)
- Ensure the database user has
CREATE TABLEandINSERTprivileges - If the load partially completed, try again — the loader uses upserts and is safe to re-run
Recommend API returns 0 decisions
Recommend API returns 0 decisions
Cause: The most common reason is that no Decision Flow is published. The Recommend API only evaluates published flows.Fix:
- Go to Studio > Decision Flows
- Open your flow and click Publish
- Verify the flow has active offers assigned to it
- Ensure the
channelandplacementin your API request match the flow configuration
API Errors
All KaireonAI API routes return standard HTTP status codes. Here is a reference for the most common error responses.| Status | Meaning | Common Cause | Fix |
|---|---|---|---|
| 401 | Unauthorized | Missing X-Tenant-Id header or invalid/expired session | Include the X-Tenant-Id header in every API request. Re-authenticate if session expired. |
| 403 | Forbidden | User role lacks permission (admin/editor/viewer) | Check the user’s role. Write operations require admin or editor. |
| 404 | Not Found | Resource does not exist, or belongs to a different tenant | Verify the resource ID and that the X-Tenant-Id matches the owning tenant. |
| 409 | Conflict | Duplicate key violation, or rowVersion mismatch (optimistic locking) | Re-fetch the resource to get the latest rowVersion, then retry the update. |
| 429 | Too Many Requests | Rate limit exceeded | Wait for the duration in the Retry-After header before retrying. See Rate Limiting below. |
| 500 | Internal Server Error | Unhandled exception on the server | Check server logs. If reproducible, file a bug with the request payload. |
Rate Limiting
KaireonAI uses a sliding-window rate limiter. When you receive a429 response, the Retry-After header tells you how many seconds to wait. The X-RateLimit-Remaining header shows how many requests remain in the current window.
Decision Flow Issues
No Offers Returned
If the Recommend API returns an empty list, work through this checklist:- Offers are active — Check that the offer’s
statusisactive(notdraftorpaused) - Schedule window — Verify
startDateandendDateencompass the current date - Budget remaining — Check the offer has not exhausted its decision or cost budget
- Flow inventory — The offer must be assigned to the Decision Flow being evaluated
- Qualification rules passing — Review the qualification rules attached to the offer; test with the exact customer attributes being sent
- Contact policies not suppressing — Check that contact policy limits (frequency caps, channel fatigue) are not filtering out the offer for this customer
- Channel/placement match — The request’s
channelandplacementmust match what the flow is configured for
Scoring Returns 0
- Model configured? Verify a scoring model is assigned to the Decision Flow and that it has valid weights
- Circuit breaker tripped? If the model’s error rate exceeded the threshold, the circuit breaker opens and scoring returns a fallback value. Check the Operations Dashboard for circuit breaker status
- Model health — Check the model health dashboard for drift or degraded performance
Wrong Offers Returned
- Flow routing — Ensure the
channelandplacementin the Recommend request match the intended Decision Flow - Qualification rule scopes — Rules scoped to the wrong category or sub-category can inadvertently include/exclude offers
- Optimization weights — If offers are returned but in an unexpected order, review the portfolio optimization profile weights (revenue, margin, propensity, engagement)
Health Checks
KaireonAI exposes two health endpoints for monitoring and orchestration.GET /api/health
Returns the overall system health including database connectivity, Redis status, and circuit breaker states.| Status | HTTP Code | Meaning |
|---|---|---|
ok | 200 | All systems healthy |
degraded (200) | 200 | Database is up, but Redis is down or a circuit breaker is open |
degraded (503) | 503 | Database is unreachable |
A
degraded status with HTTP 200 means the platform can still serve requests with reduced functionality (e.g., no caching, fallback scoring). A 503 means the database is down and the platform cannot process decisions.GET /api/ready
A readiness probe suitable for Kubernetes or load balancer health checks. Returns 200 only when both database and cache are connected.| Status | HTTP Code | Meaning |
|---|---|---|
ready | 200 | All dependencies healthy |
degraded | 503 | Database is disconnected |
Debugging with Decision Traces
Decision traces provide a forensic log of every step in the decision pipeline — which offers were considered, which filters removed them, and the final scoring/ranking.Enabling Traces
- Go to Settings > Tenant Settings
- Enable Decision Tracing
- Set a sample rate (e.g.,
0.1for 10% of requests, or1.0for all requests during debugging)
Reading a Trace
Each trace contains:- Request context — channel, placement, customer ID, attributes sent
- Candidate set — all offers that entered the pipeline
- Filter stages — which offers were removed at each stage (qualification, contact policy, budget, schedule) and why
- Scoring — the raw and weighted scores for each surviving offer
- Final ranking — the ordered list returned to the caller
Finding Why an Offer Was Filtered
- Go to Studio > Decision Flows and open the flow
- Click Recent Traces to see the latest decision trace results
- Search by customer ID or request ID
- Expand the trace and look at each filter stage — the filtered offer will show the stage name and reason (e.g.,
qualification_rule: min_balance >= 1000 failed)
Database Issues
Schema Push Fails
- Connection error — Verify
DATABASE_URLin.env(see Startup Issues) - Schema conflict — If you changed a column type on an existing table with data, Prisma may refuse. Use
npx prisma db push --accept-data-lossonly if you are okay losing data in that column - Permission denied — Ensure the database user has DDL privileges (
CREATE TABLE,ALTER TABLE)
Migration Status Check
Connection Pool Exhaustion
Symptoms: requests hang or timeout,P2024: Timed out fetching a new connection from the connection pool errors.
The default pool is configured with a maximum of 50 connections and a 2-second connection timeout.
Fix:
- Check for long-running queries or uncommitted transactions
- Increase the pool size via the
PG_POOL_MAXenvironment variable if your database supports more connections - Ensure the application is using the Prisma singleton (not creating new clients per request)
Redis Issues
Rate Limiter Not Working as Expected
If rate limits are inconsistent across nodes, Redis may not be connected. The rate limiter falls back to in-memory mode when Redis is unavailable, which means each process tracks limits independently. Check Redis connectivity:"unavailable" or "disconnected", verify your Redis connection configuration.
Stale Cache Data
If you see outdated data after making changes:- Clear the Redis cache by restarting Redis or flushing the relevant keys
- Check that cache invalidation is wired up correctly for the entity you changed
- As a workaround, restart the application to clear in-memory caches
Redis Connection Errors
Common causes:- Redis not running — Start your Redis instance
- Wrong host/port — Verify
REDIS_URLin your.env - Max connections exceeded — Check Redis
maxclientssetting - Network/firewall — Ensure the application can reach the Redis host
KaireonAI is designed for graceful degradation. If Redis is unavailable, the platform continues to operate — caching and distributed rate limiting fall back to in-memory alternatives. However, performance and accuracy of rate limits may be reduced.
Debug Mode
When standard logs are not enough, enable debug mode for verbose output across all subsystems.Verbose Logging
SetLOG_LEVEL=debug to see detailed internal operations — query execution, cache hits/misses, scoring calculations, and middleware processing:
Decision Traces
For deep visibility into why the Recommend API returned specific results, enable decision tracing:- Go to Settings > General > Decision Tracing
- Toggle tracing on and set the sample rate to
1.0(100%) for debugging - Make a Recommend API call
- Go to Studio > Decision Flows > Recent Traces to inspect the step-by-step pipeline execution
API Request IDs
Every API response includes anx-request-id header. Use this to correlate a specific client request with its server-side processing:
Getting Help
If the troubleshooting steps above do not resolve your issue:GitHub Issues
Search existing issues or file a new one. Include your error message,
recommendationId, and steps to reproduce.Documentation
Full platform documentation including API reference, deployment guides, and tutorials.
- Error message — the full error text, not a summary
- recommendationId / x-request-id — from the API response
- Steps to reproduce — what you did before the error occurred
- Environment — Docker or local dev, OS, Node.js version, PostgreSQL version
- Relevant logs — the surrounding log lines (with
LOG_LEVEL=debugif possible)
Related
Operations Dashboard
Monitor pipeline metrics, DLQ, and circuit breakers
Decision Traces
Forensic tracing of decision pipeline execution
Architecture Overview
System architecture and scaling guidance