Skip to content

Troubleshooting

Common errors, root causes, and verified fixes across the Kirak runtime.



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:
    "database": {
    "type": "postgres",
    "host": "localhost",
    "port": 5432,
    "user": "myuser",
    "name": "myapp"
    }
    And set DB_PASSWORD in .env.

  • Root Cause: An access.condition rule 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 with AND/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 .

  1. Secret Key Mismatch: The token was minted using a different KIRAK_AUTH_JWT_SECRET_KEY.
  2. Algorithm Mismatch: The token header declares an algorithm that does not match auth.jwt_algorithm in kirak.json (default HS256).

  • 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-email with the token), or mark is_verified: true in 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”
  1. Verify the JWT role claim matches an entry in the model’s access block.
  2. Check if the model defines an access block at all – models without an access block deny all operations by default.
  3. Check the RLS condition: if the user’s JWT lacks a claim referenced in {variable}, the condition evaluates to NULL (failing closed).

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.

  • Root Cause: Total pool connections across all worker processes exceeded max_connections on the database server.
  • Fix: Reduce database.pool_max in kirak.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_seconds in kirak.json (e.g. to 1800 or 3600) 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:
    1. Revert edits to the migration file, or
    2. 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';

  1. Verify the hook was registered inside on_kirak_ready(kirak). Hooks registered after startup do not take effect.
  2. Check logs/kirak.log for execution errors.
  3. Ensure the event name matches exactly (e.g. after_create, not after_created).

  • Root Cause: The hook execution duration exceeded hook_timeout_seconds in kirak.json (default 5.0 seconds).
  • Fix: Move long-running tasks (API calls, email deliveries) to background tasks or scheduler jobs, or raise hook_timeout_seconds in kirak.json.

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:
    KIRAK_STORAGE_<INSTANCE>_ACCESS_KEY=...
    KIRAK_STORAGE_<INSTANCE>_SECRET_KEY=...
    For an instance named main, set KIRAK_STORAGE_MAIN_ACCESS_KEY.

  • 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, call kirak.storage.get_url(path, expires=3600) to generate an active signed URL.

  • 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.

  • Root Cause: The scheduler worker runs embedded within the main application process.
  • Verification Steps:
    1. Confirm "scheduler" is listed in modules in kirak.json.
    2. Check startup logs for scheduler worker initialization.
    3. If using the database backend, verify pending rows in scheduler_jobs.
    4. If using Redis, verify KIRAK_SCHEDULER_<INSTANCE>_URL is set and reachable.

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 operation points 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.