{"record":{"id":"feb2202eb98eed09","repo":"langgenius/dify","slug":"qdrant-url-is-required","errorCode":null,"errorMessage":"Qdrant URL is required.","messagePattern":"Qdrant URL is required\\.","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/commands/vector.py","lineNumber":355,"sourceCode":"@click.option(\"--field\", default=\"metadata.doc_id\", prompt=False, help=\"Index field , default is metadata.doc_id.\")\ndef add_qdrant_index(field: str):\n    click.echo(click.style(\"Starting Qdrant index creation.\", fg=\"green\"))\n\n    create_count = 0\n\n    try:\n        bindings = db.session.scalars(select(DatasetCollectionBinding)).all()\n        if not bindings:\n            click.echo(click.style(\"No dataset collection bindings found.\", fg=\"red\"))\n            return\n        import qdrant_client\n        from dify_vdb_qdrant.qdrant_vector import PathQdrantParams, QdrantConfig\n        from qdrant_client.http.exceptions import UnexpectedResponse\n        from qdrant_client.http.models import PayloadSchemaType\n\n        for binding in bindings:\n            if dify_config.QDRANT_URL is None:\n                raise ValueError(\"Qdrant URL is required.\")\n            qdrant_config = QdrantConfig(\n                endpoint=dify_config.QDRANT_URL,\n                api_key=dify_config.QDRANT_API_KEY,\n                root_path=current_app.root_path,\n                timeout=dify_config.QDRANT_CLIENT_TIMEOUT,\n                grpc_port=dify_config.QDRANT_GRPC_PORT,\n                prefer_grpc=dify_config.QDRANT_GRPC_ENABLED,\n            )\n            try:\n                params = qdrant_config.to_qdrant_params()\n                # Check the type before using\n                if isinstance(params, PathQdrantParams):\n                    # PathQdrantParams case\n                    client = qdrant_client.QdrantClient(path=params.path)\n                else:\n                    # UrlQdrantParams case - params is UrlQdrantParams\n                    client = qdrant_client.QdrantClient(\n                        url=params.url,","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/commands/vector.py#L337-L373","documentation":"ValueError raised in the add-qdrant-index command loop when dify_config.QDRANT_URL is None. The command needs to construct a QdrantConfig for each binding, and without a QDRANT_URL there is no endpoint to connect to. The check is inside the per-binding loop but the value is constant, so it fails on the first binding.","triggerScenarios":"Triggered when running `add-qdrant-index` while the QDRANT_URL environment/config value is unset (None), provided at least one DatasetCollectionBinding exists.","commonSituations":"The deployment uses a different vector store so QDRANT_URL was never set, the env var was misspelled, or the config was not loaded for the CLI context.","solutions":["Set QDRANT_URL in the environment or .env (e.g. QDRANT_URL=http://localhost:6333).","Confirm the active VectorType is actually Qdrant; if not, this command does not apply.","Reload the config after setting the env var (restart the worker/CLI context).","Verify with `python -c \"from configs import dify_config; print(dify_config.QDRANT_URL)\"`."],"exampleFix":"# before\n# .env has no QDRANT_URL\nflask add-qdrant-index  # raises 'Qdrant URL is required.'\n\n# after\n# .env\nQDRANT_URL=http://qdrant:6333\nQDRANT_API_KEY=\nflask add-qdrant-index","handlingStrategy":"validation","validationCode":"from configs import dify_config\n\ndef qdrant_configured() -> bool:\n    return dify_config.QDRANT_URL is not None\n\n# preflight\nif not qdrant_configured():\n    raise SystemExit(\"QDRANT_URL is not set; configure it before running add-qdrant-index\")","typeGuard":"def qdrant_url_is_set() -> bool:\n    return bool(getattr(dify_config, \"QDRANT_URL\", None))","tryCatchPattern":"try:\n    run_add_qdrant_index(field)\nexcept ValueError as exc:\n    if \"Qdrant URL is required\" in str(exc):\n        click.echo(\"Set QDRANT_URL in the environment and retry.\", err=True)\n    raise","preventionTips":["Set QDRANT_URL (and QDRANT_API_KEY if needed) in .env before running the command.","Confirm VectorType is Qdrant; otherwise this command is irrelevant.","Reload config after changing env vars.","Add a preflight check at command start rather than inside the binding loop."],"tags":["backend","cli","vector-store","qdrant","config","missing-env"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}