{"record":{"id":"cab603d9c6dbe5a9","repo":"invoke-ai/InvokeAI","slug":"jwt-secret-not-found-in-database-this-should-have","errorCode":null,"errorMessage":"JWT secret not found in database. This should have been created during database migration. Please ensure database migrations have been run successfully.","messagePattern":"JWT secret not found in database\\. This should have been created during database migration\\. Please ensure database migrations have been run successfully\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"invokeai/app/services/app_settings/app_settings_service.py","lineNumber":70,"sourceCode":"                ON CONFLICT(key) DO UPDATE SET\n                    value = excluded.value,\n                    updated_at = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW');\n                \"\"\",\n                (key, value),\n            )\n\n    def get_jwt_secret(self) -> str:\n        \"\"\"Get the JWT secret key from the database.\n\n        Returns:\n            The JWT secret key\n\n        Raises:\n            RuntimeError: If the JWT secret is not found in the database\n        \"\"\"\n        secret = self.get(\"jwt_secret\")\n        if secret is None:\n            raise RuntimeError(\n                \"JWT secret not found in database. This should have been created during database migration. \"\n                \"Please ensure database migrations have been run successfully.\"\n            )\n        return secret\n","sourceCodeStart":52,"sourceCodeEnd":75,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/app_settings/app_settings_service.py#L52-L75","documentation":"get_jwt_secret() reads the 'jwt_secret' key from the app-settings database and raises RuntimeError when it is absent. The secret is supposed to be created during database migrations, so its absence means the settings store was never migrated or the row was lost.","triggerScenarios":"Any call to get_jwt_secret() when self.get('jwt_secret') returns None: running the app against a pre-migration or empty database, a DB file replaced or restored from an old backup without the jwt_secret row, or a failed/partial migration.","commonSituations":"Fresh checkout pointing at a stale invokeai.db; upgrading InvokeAI without running migrations; moving the DB between machines; manually editing/deleting rows in the settings table.","solutions":["Run database migrations (e.g. invokeai-db-maintenance / the app's migration path) so jwt_secret is created","Back up and delete the old DB file (or just the stale settings table) and let InvokeAI re-initialize with fresh migrations","Restore jwt_secret manually into the settings table if you need existing tokens to remain valid"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"secret = app_settings.get(\"jwt_secret\")\nif secret is None:\n    raise RuntimeError(\"jwt_secret missing; run DB migrations first\")","typeGuard":null,"tryCatchPattern":"try:\n    secret = app_settings.get_jwt_secret()\nexcept RuntimeError:\n    run_database_migrations()\n    secret = app_settings.get_jwt_secret()","preventionTips":["Run migrations as part of every upgrade before starting the server","Back up invokeai.db together with config when moving installs","Never hand-edit the settings table"],"tags":["runtime-error","jwt","database","migration"],"backgroundTag":"missing-jwt-secret","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}