{"record":{"id":"ae900f40cf97c8b2","repo":"crewAIInc/crewAI","slug":"index-name-did-not-complete-in-wait-until-comp","errorCode":null,"errorMessage":"{index_name=} did not complete in {wait_until_complete}!","messagePattern":"(.+?) did not complete in (.+?)!","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/mongodb_vector_search_tool/utils.py","lineNumber":121,"sourceCode":"\ndef _wait_for_predicate(\n    predicate: Callable[[], bool], err: str, timeout: float = 120, interval: float = 0.5\n) -> None:\n    \"\"\"Generic to block until the predicate returns true.\n\n    Args:\n        predicate (Callable[, bool]): A function that returns a boolean value\n        err (str): Error message to raise if nothing occurs\n        timeout (float, optional): Wait time for predicate. Defaults to TIMEOUT.\n        interval (float, optional): Interval to check predicate. Defaults to DELAY.\n\n    Raises:\n        TimeoutError: _description_\n    \"\"\"\n    start = monotonic()\n    while not predicate():\n        if monotonic() - start > timeout:\n            raise TimeoutError(err)\n        sleep(interval)\n","sourceCodeStart":103,"sourceCodeEnd":123,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/mongodb_vector_search_tool/utils.py#L103-L123","documentation":"A polling helper in the MongoDB vector search tool utils: it loops calling predicate() every `interval` seconds until it returns True or `timeout` (default TIMEOUT) elapses, at which point it raises TimeoutError(err). In this tool it is used to wait for a MongoDB Search Index (e.g. an Atlas vector index) to finish building, so the error means the named index ({index_name}) was still not ready when the wait budget expired.","triggerScenarios":"Calling upsert/index-creation flows right after creating a new Atlas vector search index — large collections take minutes to build; using a free/shared Atlas tier with slow index builds; an index that failed to build (bad definition) so the predicate never becomes true; a too-small wait_until_complete value.","commonSituations":"First run on a fresh collection where the vector index was just created; big collections with many embeddings; typo'd index definition leaving it in a failed state; CI time budgets shorter than build time.","solutions":["Retry after waiting — Atlas index builds often just need more time; check the Atlas UI for index status/size","Increase wait_until_complete / the timeout argument passed to the wait helper","Verify in Atlas UI > Search that the index is BUILDING vs FAILED; fix the definition if FAILED","Warm up separately: create the index and let it finish before running the tool (decouple index creation from ingestion)"],"exampleFix":"# before\ntool.upsert([\"text\"], ids=[\"1\"], metadatas=[{}])  # TimeoutError on fresh index\n\n# after\n# create/verify index in Atlas first, then allow a larger budget\ntool = MongoDBVectorSearchTool(\n    collection_name=\"docs\",\n    index_name=\"vector_index\",\n    wait_until_complete=600,  # give large collections room\n)","handlingStrategy":"retry","validationCode":"def index_ready(client, coll, index_name: str) -> bool:\n    indexes = list(coll.list_search_indexes())\n    return any(\n        i.get(\"name\") == index_name and i.get(\"status\", \"\").upper() in (\"READY\", \"ACTIVE\")\n        for i in indexes\n    )","typeGuard":null,"tryCatchPattern":"import time\n\nfor attempt in range(5):\n    try:\n        tool.upsert(texts, ids=ids)\n        break\n    except TimeoutError:\n        if attempt == 4:\n            raise\n        time.sleep(60)  # index build may just need more time","preventionTips":["Create vector indexes ahead of ingestion, not during","Set wait_until_complete proportional to collection size","Check Atlas UI for FAILED index builds instead of waiting on a broken index"],"tags":["mongodb","atlas","index-build","timeout","polling"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}