{"record":{"id":"5dccdfbfbf453379","repo":"BerriAI/litellm","slug":"input-must-be-a-string-or-a-list","errorCode":null,"errorMessage":"input must be a string or a list","messagePattern":"input must be a string or a list","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/caching/caching_handler.py","lineNumber":378,"sourceCode":"                        self.preset_cache_key\n                        or self.request_kwargs.get(\"cache_key\")\n                        or litellm.cache.get_cache_key(**self.request_kwargs)\n                    )\n                    if hasattr(cached_result, \"_hidden_params\"):\n                        cached_result._hidden_params[\"cache_key\"] = cache_key\n                    return CachingHandlerResponse(cached_result=cached_result)\n        return CachingHandlerResponse(cached_result=cached_result)\n\n    def handle_kwargs_input_list_or_str(self, kwargs: dict[str, Any]) -> list[str]:\n        \"\"\"\n        Handles the input of kwargs['input'] being a list or a string\n        \"\"\"\n        if isinstance(kwargs[\"input\"], str):\n            return [kwargs[\"input\"]]\n        elif isinstance(kwargs[\"input\"], list):\n            return kwargs[\"input\"]\n        else:\n            raise ValueError(\"input must be a string or a list\")\n\n    def _extract_model_from_cached_results(self, non_null_list: list[tuple[int, CachedEmbedding]]) -> str | None:\n        \"\"\"\n        Helper method to extract the model name from cached results.\n\n        Args:\n            non_null_list: List of (idx, cr) tuples where cr is the cached result dict\n\n        Returns:\n            Optional[str]: The model name if found, None otherwise\n        \"\"\"\n        for _, cr in non_null_list:\n            if isinstance(cr, dict) and cr.get(\"model\"):\n                return cr[\"model\"]\n        return None\n\n    def _process_async_embedding_cached_response(\n        self,","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/caching/caching_handler.py#L360-L396","documentation":"Guard inside CachingHandler's kwargs-input normalization helper: the value passed for the model input is neither a string nor a list, so it cannot be normalized into the list-of-strings form the caching layer expects.","triggerScenarios":"Thrown at litellm/caching/caching_handler.py:378 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass input as a string or a list of strings to the embedding/caching call.","Validate the input type before invoking litellm.embedding so non-string, non-list values are rejected early."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}