{"record":{"id":"9d667a54150ea3f1","repo":"BerriAI/litellm","slug":"invalid-value-passed-in-for-aget-assistants-only","errorCode":null,"errorMessage":"Invalid value passed in for aget_assistants. Only bool or None allowed","messagePattern":"Invalid value passed in for aget_assistants\\. Only bool or None allowed","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/assistants/main.py","lineNumber":83,"sourceCode":"            model=\"\",\n            custom_llm_provider=custom_llm_provider,\n            original_exception=e,\n            completion_kwargs={},\n            extra_kwargs=kwargs,\n        )\n\n\ndef get_assistants(\n    custom_llm_provider: Literal[\"openai\", \"azure\"],\n    client: Any | None = None,\n    api_key: str | None = None,\n    api_base: str | None = None,\n    api_version: str | None = None,\n    **kwargs,\n) -> SyncCursorPage[Assistant]:\n    aget_assistants: Final[bool | None] = kwargs.pop(\"aget_assistants\", None)\n    if aget_assistants is not None and not isinstance(aget_assistants, bool):\n        raise Exception(\"Invalid value passed in for aget_assistants. Only bool or None allowed\")\n    optional_params: Final = GenericLiteLLMParams(api_key=api_key, api_base=api_base, api_version=api_version, **kwargs)\n    litellm_params_dict: Final = get_litellm_params(**kwargs)\n\n    ### TIMEOUT LOGIC ###\n    timeout = optional_params.timeout or kwargs.get(\"request_timeout\", 600) or 600\n    # set timeout for 10 minutes by default\n\n    if (\n        timeout is not None\n        and isinstance(timeout, httpx.Timeout)\n        and supports_httpx_timeout(custom_llm_provider) is False\n    ):\n        read_timeout: Final = timeout.read or 600\n        timeout = read_timeout  # default 10 min timeout\n    elif timeout is not None and not isinstance(timeout, httpx.Timeout):\n        timeout = float(timeout)\n    elif timeout is None:\n        timeout = 600.0","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/assistants/main.py#L65-L101","documentation":"Raised by litellm.assistants.get_assistants when the caller passes an 'aget_assistants' kwarg that is neither a bool nor None. This kwarg is a LiteLLM-internal switch used to route between the sync and async implementations, and the function guards its type before proceeding. Note this variant raises a bare Exception (unlike the sibling functions which raise ValueError).","triggerScenarios":"Calling litellm.get_assistants(...) (or the a* variant) with aget_assistants set to a non-bool, e.g. aget_assistants='true', aget_assistants=1, or aget_assistants='yes'. Because it is popped from **kwargs, any truthy string triggers it.","commonSituations":"Passing CLI/env-var flags as strings into the kwargs dict; copying code from a tutorial that used a string flag; programmatically building kwargs where the flag came from JSON/YAML as a string.","solutions":["Pass a real boolean: aget_assistants=True (or omit it for None).","If the flag comes from config/env, coerce it: aget_assistants=parse_bool(value).","Remember most users should never set this flag — call the aget_assistants async function directly instead of toggling it."],"exampleFix":"# before\nres = litellm.get_assistants(custom_llm_provider=\"openai\", aget_assistants=\"true\")\n\n# after\nres = await litellm.aget_assistants(custom_llm_provider=\"openai\")\n# or: litellm.get_assistants(custom_llm_provider=\"openai\", aget_assistants=True)","handlingStrategy":"type-guard","validationCode":"if \"aget_assistants\" in kwargs and not isinstance(kwargs[\"aget_assistants\"], (bool, type(None))):\n    kwargs[\"aget_assistants\"] = parse_bool(kwargs[\"aget_assistants\"])","typeGuard":"def is_valid_assistants_flag(v) -> bool:\n    return v is None or isinstance(v, bool)","tryCatchPattern":"try:\n    assistants = litellm.get_assistants(custom_llm_provider=\"openai\", **kwargs)\nexcept Exception as e:\n    if \"aget_assistants\" in str(e):\n        kwargs.pop(\"aget_assistants\", None)\n        assistants = litellm.get_assistants(custom_llm_provider=\"openai\", **kwargs)\n    else:\n        raise","preventionTips":["Never pass these internal flags; use the public aget_assistants async function instead.","Centralize bool parsing (argparse/env) with one parse_bool helper used everywhere.","Lint for string literals passed to known-bool kwargs in your codebase."],"tags":["assistants","api-misuse","type-validation","python"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}