{"record":{"id":"f8d9e69204d60871","repo":"iflytek/astron-agent","slug":"1-chunk-query-url-is-not-set","errorCode":"-1","errorMessage":"CHUNK_QUERY_URL is not set","messagePattern":"CHUNK_QUERY_URL is not set","errorType":"error_code","errorClass":"PluginExc","httpStatus":null,"severity":"error","filePath":"core/agent/service/plugin/knowledge.py","lineNumber":98,"sourceCode":"            if self.rag_type == \"Ragflow-RAG\" and self.dataset_ids:\n                data[\"match\"][\"datasetId\"] = self.dataset_ids\n\n            sp.add_info_events({\"request-data\": json.dumps(data, ensure_ascii=False)})\n\n            if not self.repo_ids:\n                empty_resp: Dict[str, Any] = {}\n                sp.add_info_events(\n                    {\"response-data\": json.dumps(empty_resp, ensure_ascii=False)}\n                )\n                retrieval_span.set_attributes(\n                    self._retrieval_attributes(output_value=empty_resp)\n                )\n                return empty_resp\n\n            try:\n                query_url = os.getenv(\"CHUNK_QUERY_URL\")\n                if not query_url:\n                    raise PluginExc(-1, \"CHUNK_QUERY_URL is not set\")\n                async with aiohttp.ClientSession() as session:\n                    timeout = aiohttp.ClientTimeout(\n                        total=int(os.getenv(\"KNOWLEDGE_CALL_TIMEOUT\", \"90\"))\n                    )\n                    headers = self._headers()\n                    async with session.post(\n                        query_url, headers=headers, json=data, timeout=timeout\n                    ) as response:\n\n                        sp.add_info_events(\n                            {\"response-data\": str(await response.read())}\n                        )\n\n                        response.raise_for_status()\n                        if response.status == 200:\n                            resp: Dict[str, Any] = await response.json()\n                            sp.add_info_events(\n                                {\"response-data\": json.dumps(resp, ensure_ascii=False)}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/agent/service/plugin/knowledge.py#L80-L116","documentation":"KnowledgePlugin.retrieve() reads CHUNK_QUERY_URL to know where the knowledge/RAG chunk-query service lives. If the env var is absent it raises PluginExc(code=-1) before making any HTTP call — a fail-fast guard against an unconfigured retrieval endpoint.","triggerScenarios":"Invoking the knowledge plugin with non-empty repo_ids when CHUNK_QUERY_URL is not present in the Agent service environment (knowledge.py:96-98).","commonSituations":"Agent container started without the knowledge service URL env var; .env file not loaded; value named differently in a new deployment template; the variable lost when copying compose files between environments.","solutions":["Set CHUNK_QUERY_URL (e.g. http://knowledge:8080/chunk/query) in the Agent service environment and restart it","Add the variable to docker-compose/helm values so every deployment includes it","Locally, export CHUNK_QUERY_URL or put it in the .env file the service loads","Add a startup readiness check that validates required env vars before serving traffic"],"exampleFix":"// before\nexport KNOWLEDGE_CALL_TIMEOUT=90\n// after\nexport CHUNK_QUERY_URL=http://knowledge-service:8080/api/chunk/query\nexport KNOWLEDGE_CALL_TIMEOUT=90","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv(\"CHUNK_QUERY_URL\"):\n    raise RuntimeError(\"CHUNK_QUERY_URL must be set before invoking the knowledge plugin\")","typeGuard":"def knowledge_configured() -> bool:\n    url = os.getenv(\"CHUNK_QUERY_URL\")\n    return bool(url and url.startswith((\"http://\", \"https://\")))","tryCatchPattern":"try:\n    result = await plugin.retrieve(span)\nexcept PluginExc as e:\n    if \"CHUNK_QUERY_URL\" in str(e):\n        logger.error(\"knowledge service URL missing; set CHUNK_QUERY_URL and restart\")\n    raise","preventionTips":["Declare CHUNK_QUERY_URL in compose/helm env blocks for every environment","Validate required env vars at service startup, not at request time","Keep a checked-in .env.example listing all knowledge plugin variables"],"tags":["config","env","knowledge-base"],"backgroundTag":"missing-env-var","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}