{"record":{"id":"90d937d1159fb5b6","repo":"microsoft/semantic-kernel","slug":"astra-db-request-error-response-dict-errors","errorCode":null,"errorMessage":"Astra DB request error - {response_dict['errors']}","messagePattern":"Astra DB request error - (.+?)","errorType":"exception","errorClass":"ServiceResponseException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/astradb/astra_client.py","lineNumber":57,"sourceCode":"        self.request_base_url = (\n            f\"https://{self.astra_id}-{self.astra_region}.apps.astra.datastax.com/api/json/v1/{self.keyspace_name}\"\n        )\n        self.request_header = {\n            \"x-cassandra-token\": self.astra_application_token,\n            \"Content-Type\": \"application/json\",\n            \"User-Agent\": ASTRA_CALLER_IDENTITY,\n        }\n        self._session = session\n\n    async def _run_query(self, request_url: str, query: dict):\n        async with (\n            AsyncSession(self._session) as session,\n            session.post(request_url, data=json.dumps(query), headers=self.request_header) as response,\n        ):\n            if response.status == 200:\n                response_dict = await response.json()\n                if \"errors\" in response_dict:\n                    raise ServiceResponseException(f\"Astra DB request error - {response_dict['errors']}\")\n                return response_dict\n            raise ServiceResponseException(f\"Astra DB not available. Status : {response}\")\n\n    async def find_collections(self, include_detail: bool = True):\n        \"\"\"Finds all collections in the keyspace.\"\"\"\n        query = {\"findCollections\": {\"options\": {\"explain\": include_detail}}}\n        result = await self._run_query(self.request_base_url, query)\n        return result[\"status\"][\"collections\"]\n\n    async def find_collection(self, collection_name: str):\n        \"\"\"Finds a collection in the keyspace.\"\"\"\n        collections = await self.find_collections(False)\n        found = False\n        for collection in collections:\n            if collection == collection_name:\n                found = True\n                break\n        return found","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/astradb/astra_client.py#L39-L75","documentation":"Raised by `AstraClient._run_query` when the HTTP response from Astra DB returns status 200 but the JSON body contains an `errors` key. Astra DB conveys application-level/data-plane errors (e.g. invalid query, missing collection, key issues) inside a 200 response body, so the client inspects the payload and throws a `ServiceResponseException` embedding the raw error list.","triggerScenarios":"Any async Astra operation (`find_collections`, `find_collection`, `create_collection`, `find_documents`, etc.) whose POST to the Astra REST API returns `{..., \"errors\": [...]}`. Common triggers: referencing a non-existent collection/keyspace, malformed vector dimensions in the query, an incompatible API payload, or a token that authenticates but lacks data-plane permission on the resource.","commonSituations":"Misconfigured collection name or keyspace; embedding dimension mismatch between stored collection and query; stale app token scoped to the wrong database; Astra rolling out a backend change that alters the response shape; passing a filter or option field Astra rejects.","solutions":["Read the `errors` array in the message to identify the precise Astra-side reason and address it (e.g. create the missing collection, fix the dimension).","Verify the collection/keyspace names and that they exist via `find_collections`.","Confirm the embedding dimension used in queries matches the collection's configured dimension.","Ensure the Astra application token has the correct scope and belongs to the right database/region.","Retry on transient Astra-side errors with exponential backoff."],"exampleFix":"// before\nawait store.get(\"my_collection\", \"missing-key\")  # 200 with errors payload\n\n// after\ncols = await store.get_collections()\nassert \"my_collection\" in cols, f\"collection missing; available: {cols}\"\nrec = await store.get(\"my_collection\", \"valid-key\")","handlingStrategy":"try-catch","validationCode":"# pre-flight: confirm the collection exists and dims match\nasync def ensure_astra_ready(store, collection, dim):\n    cols = await store.get_collections()\n    if collection not in cols:\n        await store.create_collection(collection, dimension_num=dim)\n    return True","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceResponseException\ntry:\n    rec = await store.get(\"coll\", \"k\")\nexcept ServiceResponseException as e:\n    msg = str(e)\n    if \"request error\" in msg:\n        errors = msg.split(\"-\", 1)[1]\n        # parse the Astra errors list and decide: create collection, fix dims, etc.\n        raise\n    raise","preventionTips":["Always confirm the collection/keyspace exists before querying.","Keep query embedding dimensions equal to the collection's configured dimension.","Log the raw `errors` array so data-plane failures are diagnosable.","Scope the Astra token to the correct database and rotate it before expiry."],"tags":["astra-db","data-plane","service-response","network","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}