Troubleshooting
Common errors, root causes, and verified fixes across the Kirak runtime.
Quick Navigation
Section titled “Quick Navigation”- Startup Errors
- Authentication Errors
- Database & Migration Errors
- Hook Errors
- Storage Errors
- Scheduler Errors
- MCP Errors
Startup Errors
Section titled “Startup Errors”Container stops with exit code 0 right after starting
Section titled “Container stops with exit code 0 right after starting”- Root Cause: Uvicorn was started with
--workers N(where N > 1). When child workers fail during boot, Uvicorn logs the error and exits with code 0 instead of propagating a crash code. - Fix: In containerized environments, run one Uvicorn process per container (
uvicorn main:app --host 0.0.0.0 --port 8000), or run under Gunicorn (gunicorn -k uvicorn.workers.UvicornWorker). Both exit with code 3 on boot failure, allowing orchestrators to detect the crash.
ValueError: KIRAK_AUTH_JWT_SECRET_KEY must be at least 32 bytes
Section titled “ValueError: KIRAK_AUTH_JWT_SECRET_KEY must be at least 32 bytes”- Root Cause: The JWT signing secret is missing or shorter than 32 characters.
- Fix: Generate a secure 32-byte secret and set it in
.env:Terminal window python -c "import secrets; print(secrets.token_hex(32))"KIRAK_AUTH_JWT_SECRET_KEY=<generated_value>
ConfigurationError: database.name is required
Section titled “ConfigurationError: database.name is required”- Root Cause: The database name is missing in
kirak.json. Only passwords and sensitive connection secrets are loaded from environment variables. - Fix: Define the database connection block in
kirak.json:And set"database": {"type": "postgres","host": "localhost","port": 5432,"user": "myuser","name": "myapp"}DB_PASSWORDin.env.
ConfigurationError: Invalid RLS condition
Section titled “ConfigurationError: Invalid RLS condition”- Root Cause: An
access.conditionrule in a model violates Kirak’s strict regular grammar. - Fix: The safe grammar permits only
field operator {variable},field operator <number>,field = TRUE/FALSE,field = NULL,field IS NULL,field IS NOT NULL, combined withAND/OR. Subqueries, raw functions, and string literals are prohibited. Pass string filters through{variable}placeholders.
asyncmy or asyncpg .pyd blocked by Windows Application Control
Section titled “asyncmy or asyncpg .pyd blocked by Windows Application Control”- Root Cause: On Windows, AppLocker or WDAC blocks compiled C-extensions (
.pyd) from executing inside untrusted directories. - Fix: Recreate your virtual environment under your trusted user profile directory:
Terminal window python -m venv C:\Users\<Username>\venvs\<ProjectName>C:\Users\<Username>\venvs\<ProjectName>\Scripts\pip.exe install -e .
Authentication Errors
Section titled “Authentication Errors”401 INVALID_TOKEN on every request
Section titled “401 INVALID_TOKEN on every request”- Secret Key Mismatch: The token was minted using a different
KIRAK_AUTH_JWT_SECRET_KEY. - Algorithm Mismatch: The token header declares an algorithm that does not match
auth.jwt_algorithminkirak.json(defaultHS256).
403 EMAIL_NOT_VERIFIED after registration
Section titled “403 EMAIL_NOT_VERIFIED after registration”- Root Cause: Kirak enforces email verification before allowing password-based login.
- Fix: Have the user complete the verification email link flow (open the link, then press Verify my email; or
POST /auth/verify-emailwith the token), or markis_verified: truein the database directly during development.
403 PERMISSION_DENIED on a route that should be accessible
Section titled “403 PERMISSION_DENIED on a route that should be accessible”- Verify the JWT
roleclaim matches an entry in the model’saccessblock. - Check if the model defines an
accessblock at all – models without anaccessblock deny all operations by default. - Check the RLS condition: if the user’s JWT lacks a claim referenced in
{variable}, the condition evaluates toNULL(failing closed).
Database and Migration Errors
Section titled “Database and Migration Errors”Concurrent requests hang on Windows SQLite
Section titled “Concurrent requests hang on Windows SQLite”- Root Cause: SQLite enforces single-writer locking. On Windows, running multiple Uvicorn worker processes against one SQLite database file can cause thread lock contention that hangs requests without logging errors.
- Fix: Run 1 worker on Windows when using SQLite (
uvicorn main:app --workers 1), or switch to MySQL or PostgreSQL.
OperationalError: too many connections
Section titled “OperationalError: too many connections”- Root Cause: Total pool connections across all worker processes exceeded
max_connectionson the database server. - Fix: Reduce
database.pool_maxinkirak.json, decrease worker process counts, or place a connection pooler (PgBouncer, ProxySQL) in front of the database.
OperationalError: connection closed / MySQL server has gone away
Section titled “OperationalError: connection closed / MySQL server has gone away”- Root Cause: Idle database connections were terminated by network firewalls or MySQL’s
wait_timeout. - Fix: Lower
database.pool_recycle_secondsinkirak.json(e.g. to1800or3600) so Kirak recycles connections before the server drops them.
Migration status shows modified for an unchanged file
Section titled “Migration status shows modified for an unchanged file”- Root Cause: The migration file on disk was edited after it was applied, altering its SHA-256 checksum.
- Fix:
- Revert edits to the migration file, or
- If the change was intentionally applied manually, update the recorded checksum in
kirak_migrations:UPDATE kirak_migrations SET checksum = '<new_checksum>' WHERE name = 'migration_name';
Hook Errors
Section titled “Hook Errors”Hook silently does nothing
Section titled “Hook silently does nothing”- Verify the hook was registered inside
on_kirak_ready(kirak). Hooks registered after startup do not take effect. - Check
logs/kirak.logfor execution errors. - Ensure the event name matches exactly (e.g.
after_create, notafter_created).
asyncio.TimeoutError in hook logs
Section titled “asyncio.TimeoutError in hook logs”- Root Cause: The hook execution duration exceeded
hook_timeout_secondsinkirak.json(default 5.0 seconds). - Fix: Move long-running tasks (API calls, email deliveries) to background tasks or scheduler jobs, or raise
hook_timeout_secondsinkirak.json.
Storage Errors
Section titled “Storage Errors”NoCredentialsError on S3 / Wasabi / Cloud Storage
Section titled “NoCredentialsError on S3 / Wasabi / Cloud Storage”- Root Cause: Storage instance credentials were not set in the environment.
- Fix: Environment variable names use the provider instance name in uppercase:
For an instance namedKIRAK_STORAGE_<INSTANCE>_ACCESS_KEY=...KIRAK_STORAGE_<INSTANCE>_SECRET_KEY=...
main, setKIRAK_STORAGE_MAIN_ACCESS_KEY.
Uploaded file URL returns 403 or 404
Section titled “Uploaded file URL returns 403 or 404”- Root Cause: The storage instance is
private(the default) and the file is being accessed without a signed URL. - Fix: Store the returned
path(not the signed URL, which expires). When serving files, callkirak.storage.get_url(path, expires=3600)to generate an active signed URL.
Scheduler Errors
Section titled “Scheduler Errors”TASK_NOT_REGISTERED (400)
Section titled “TASK_NOT_REGISTERED (400)”- Root Cause: The task name passed to
enqueue()does not match the name registered with@kirak.scheduler.task("task_name"). - Fix: Task names are case-sensitive and must match registration strings identically.
Background jobs are not processing
Section titled “Background jobs are not processing”- Root Cause: The scheduler worker runs embedded within the main application process.
- Verification Steps:
- Confirm
"scheduler"is listed inmodulesinkirak.json. - Check startup logs for scheduler worker initialization.
- If using the database backend, verify pending rows in
scheduler_jobs. - If using Redis, verify
KIRAK_SCHEDULER_<INSTANCE>_URLis set and reachable.
- Confirm
MCP Errors
Section titled “MCP Errors”Startup fails with “Invalid MCP server files”
Section titled “Startup fails with “Invalid MCP server files””- Root Cause: A file in
mcp/violates schema constraints. - Fix: Review the startup error log:
- Check that
operationpoints to a valid model or enabled module. - Ensure no duplicate tool names exist across files.
- Verify that any tool requiring confirmation sets
"requires_confirmation": true.
- Check that