{"record":{"id":"ee45ced514275bb5","repo":"Comfy-Org/ComfyUI","slug":"unsupported-database-url-url","errorCode":null,"errorMessage":"Unsupported database URL '{url}'.","messagePattern":"Unsupported database URL '(.+?)'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/database/db.py","lineNumber":70,"sourceCode":"\ndef get_alembic_config():\n    root_path = os.path.join(os.path.dirname(__file__), \"../..\")\n    config_path = os.path.abspath(os.path.join(root_path, \"alembic.ini\"))\n    scripts_path = os.path.abspath(os.path.join(root_path, \"alembic_db\"))\n\n    config = Config(config_path)\n    config.set_main_option(\"script_location\", scripts_path)\n    config.set_main_option(\"sqlalchemy.url\", args.database_url)\n\n    return config\n\n\ndef get_db_path():\n    url = args.database_url\n    if url.startswith(\"sqlite:///\"):\n        return url.split(\"///\")[1]\n    else:\n        raise ValueError(f\"Unsupported database URL '{url}'.\")\n\n\n_db_lock = None\n\ndef _acquire_file_lock(db_path):\n    \"\"\"Acquire an OS-level file lock to prevent multi-process access.\n\n    Uses filelock for cross-platform support (macOS, Linux, Windows).\n    The OS automatically releases the lock when the process exits, even on crashes.\n    \"\"\"\n    global _db_lock\n    lock_path = db_path + \".lock\"\n    _db_lock = FileLock(lock_path)\n    try:\n        _db_lock.acquire(timeout=0)\n    except Timeout:\n        raise RuntimeError(\n            f\"Could not acquire lock on database '{db_path}'. \"","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/app/database/db.py#L52-L88","documentation":"Raised by get_db_path() when args.database_url does not start with 'sqlite:///'. This ComfyUI-asset server's database layer only supports SQLite, and the URL convention is fixed: everything after 'sqlite:///' is taken as the file path. Any other scheme (postgres://, mysql://, or a bare path) is rejected upfront.","triggerScenarios":"Launching the server with --database-url postgresql://... or DATABASE_URL=mysql://...; or passing a bare relative path like 'data.db' without the sqlite:/// prefix; or 'sqlite:///' vs 'sqlite://' (two slashes = empty host, still fails the startswith check only if not matching exactly).","commonSituations":"Reusing a DATABASE_URL from another service that runs Postgres/MySQL; CI env vars carrying a generic connection string; docs/examples that show bare paths; porting expectations from an ORM stack that accepts many schemes.","solutions":["Use a SQLite URL: --database-url sqlite:///absolute/or/relative/path.db (three slashes then the path).","If you actually need a network database, this build does not support it — remove the env override and use the default SQLite location, or patch the layer yourself.","In Docker/CI, set DATABASE_URL='sqlite:////data/assets.db' (four slashes for absolute path) and ensure the directory exists and is writable."],"exampleFix":"# before\nDATABASE_URL=postgres://user:pass@db/assets\n\n# after\nDATABASE_URL=sqlite:////data/assets.db","handlingStrategy":"validation","validationCode":"import re\nSQLITE_URL = re.compile(r'^sqlite:///\\S.*$')\n\ndef usable_db_url(url: str) -> bool:\n    return bool(SQLITE_URL.match(url))","typeGuard":"def is_sqlite_url(url: str) -> bool:\n    return isinstance(url, str) and url.startswith('sqlite:///')","tryCatchPattern":"try:\n    db_path = get_db_path()\nexcept ValueError as e:\n    raise SystemExit(f'bad --database-url: {e}') from e","preventionTips":["Always launch with sqlite:///<path> (three slashes relative, four for absolute)","Don't reuse DATABASE_URL values from Postgres/MySQL services","Fail fast at startup on non-sqlite URLs instead of at first query","In containers, verify the target directory exists and is writable"],"tags":["database","configuration","sqlite","startup"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}