[FIX] AttributeError: 'str' object has no attribute 'value' when giving a text file as an attachment in certain conditions in self-hosted Khoj with Ollama models
Author: KlemetCreated Jan 10, 2025Updated Sep 1, 2026
Labelsfix
Describe the bug
When giving any text file as an attachment, and asking for a translation or a summary, in certain conditions (couldn't isolate why), the following error is produced in server-1 :
2025-01-10 13:34:34 [18:34:34.173791] ERROR uvicorn.error: Exception in ASGI h11_impl.py:411
2025-01-10 13:34:34 application
2025-01-10 13:34:34
2025-01-10 13:34:34 ╭─ Traceback (most recent call last─╮
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/uvicorn/protocols/http/h11 │
2025-01-10 13:34:34 │ _impl.py:406 in run_asgi │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 403 │ # ASGI exception wrappe │
2025-01-10 13:34:34 │ 404 │ async def run_asgi(self │
2025-01-10 13:34:34 │ 405 │ │ try: │
2025-01-10 13:34:34 │ ❱ 406 │ │ │ result = await │
2025-01-10 13:34:34 │ 407 │ │ │ │ self.scope, │
2025-01-10 13:34:34 │ 408 │ │ │ ) │
2025-01-10 13:34:34 │ 409 │ │ except BaseExceptio │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/uvicorn/middleware/proxy_h │
2025-01-10 13:34:34 │ eaders.py:70 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 67 │ │ │ │ │ port = 0 │
2025-01-10 13:34:34 │ 68 │ │ │ │ │ scope["c │
2025-01-10 13:34:34 │ 69 │ │ │
2025-01-10 13:34:34 │ ❱ 70 │ │ return await self.ap │
2025-01-10 13:34:34 │ 71 │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/fastapi/applications.py:10 │
2025-01-10 13:34:34 │ 54 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 1051 │ async def __call__(sel │
2025-01-10 13:34:34 │ 1052 │ │ if self.root_path: │
2025-01-10 13:34:34 │ 1053 │ │ │ scope["root_pa │
2025-01-10 13:34:34 │ ❱ 1054 │ │ await super().__ca │
2025-01-10 13:34:34 │ 1055 │ │
2025-01-10 13:34:34 │ 1056 │ def add_api_route( │
2025-01-10 13:34:34 │ 1057 │ │ self, │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/applications.py: │
2025-01-10 13:34:34 │ 113 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 110 │ │ scope["app"] = self │
2025-01-10 13:34:34 │ 111 │ │ if self.middleware_ │
2025-01-10 13:34:34 │ 112 │ │ │ self.middleware │
2025-01-10 13:34:34 │ ❱ 113 │ │ await self.middlewa │
2025-01-10 13:34:34 │ 114 │ │
2025-01-10 13:34:34 │ 115 │ def on_event(self, even │
2025-01-10 13:34:34 │ 116 │ │ return self.router. │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/error │
2025-01-10 13:34:34 │ s.py:187 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 184 │ │ │ # We always con │
2025-01-10 13:34:34 │ 185 │ │ │ # This allows s │
2025-01-10 13:34:34 │ 186 │ │ │ # to optionally │
2025-01-10 13:34:34 │ ❱ 187 │ │ │ raise exc │
2025-01-10 13:34:34 │ 188 │ │
2025-01-10 13:34:34 │ 189 │ def format_line(self, i │
2025-01-10 13:34:34 │ str: │
2025-01-10 13:34:34 │ 190 │ │ values = { │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/error │
2025-01-10 13:34:34 │ s.py:165 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 162 │ │ │ await send(mess │
2025-01-10 13:34:34 │ 163 │ │ │
2025-01-10 13:34:34 │ 164 │ │ try: │
2025-01-10 13:34:34 │ ❱ 165 │ │ │ await self.app( │
2025-01-10 13:34:34 │ 166 │ │ except Exception as │
2025-01-10 13:34:34 │ 167 │ │ │ request = Reque │
2025-01-10 13:34:34 │ 168 │ │ │ if self.debug: │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/sessi │
2025-01-10 13:34:34 │ ons.py:85 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 82 │ │ │ │ │ headers. │
2025-01-10 13:34:34 │ 83 │ │ │ await send(messa │
2025-01-10 13:34:34 │ 84 │ │ │
2025-01-10 13:34:34 │ ❱ 85 │ │ await self.app(scope │
2025-01-10 13:34:34 │ 86 │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /app/src/khoj/configure.py:351 in │
2025-01-10 13:34:34 │ __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 348 │ │ async def __call__( │
2025-01-10 13:34:34 │ 349 │ │ │ if scope["type" │
2025-01-10 13:34:34 │ 350 │ │ │ │ scope["path │
2025-01-10 13:34:34 │ ❱ 351 │ │ │ await self.app( │
2025-01-10 13:34:34 │ 352 │ │ │
2025-01-10 13:34:34 │ 353 │ │ def __init__(self, │
2025-01-10 13:34:34 │ 354 │ │ │ super().__init_ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/authe │
2025-01-10 13:34:34 │ ntication.py:48 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 45 │ │ if auth_result is No │
2025-01-10 13:34:34 │ 46 │ │ │ auth_result = Au │
2025-01-10 13:34:34 │ 47 │ │ scope["auth"], scope │
2025-01-10 13:34:34 │ ❱ 48 │ │ await self.app(scope │
2025-01-10 13:34:34 │ 49 │ │
2025-01-10 13:34:34 │ 50 │ @staticmethod │
2025-01-10 13:34:34 │ 51 │ def default_on_error(con │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/base. │
2025-01-10 13:34:34 │ py:188 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 185 │ │ with collapse_excgr │
2025-01-10 13:34:34 │ 186 │ │ │ async with anyi │
2025-01-10 13:34:34 │ 187 │ │ │ │ response = │
2025-01-10 13:34:34 │ ❱ 188 │ │ │ │ await respo │
2025-01-10 13:34:34 │ 189 │ │ │ │ response_se │
2025-01-10 13:34:34 │ 190 │ │
2025-01-10 13:34:34 │ 191 │ async def dispatch(self │
2025-01-10 13:34:34 │ Response: │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/base. │
2025-01-10 13:34:34 │ py:222 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 219 │ │ │ } │
2025-01-10 13:34:34 │ 220 │ │ ) │
2025-01-10 13:34:34 │ 221 │ │ │
2025-01-10 13:34:34 │ ❱ 222 │ │ async for chunk in │
2025-01-10 13:34:34 │ 223 │ │ │ await send({"ty │
2025-01-10 13:34:34 │ 224 │ │ │
2025-01-10 13:34:34 │ 225 │ │ await send({"type": │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/base. │
2025-01-10 13:34:34 │ py:179 in body_stream │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 176 │ │ │ │ │ │ │ │
2025-01-10 13:34:34 │ 177 │ │ │ │ │
2025-01-10 13:34:34 │ 178 │ │ │ │ if app_exc │
2025-01-10 13:34:34 │ ❱ 179 │ │ │ │ │ raise a │
2025-01-10 13:34:34 │ 180 │ │ │ │
2025-01-10 13:34:34 │ 181 │ │ │ response = _Str │
2025-01-10 13:34:34 │ content=body_stream(), info │
2025-01-10 13:34:34 │ 182 │ │ │ response.raw_he │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/base. │
2025-01-10 13:34:34 │ py:149 in coro │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 146 │ │ │ │ │
2025-01-10 13:34:34 │ 147 │ │ │ │ async with │
2025-01-10 13:34:34 │ 148 │ │ │ │ │ try: │
2025-01-10 13:34:34 │ ❱ 149 │ │ │ │ │ │ awa │
2025-01-10 13:34:34 │ 150 │ │ │ │ │ except │
2025-01-10 13:34:34 │ 151 │ │ │ │ │ │ app │
2025-01-10 13:34:34 │ 152 │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/cors. │
2025-01-10 13:34:34 │ py:93 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 90 │ │ │ await response( │
2025-01-10 13:34:34 │ 91 │ │ │ return │
2025-01-10 13:34:34 │ 92 │ │ │
2025-01-10 13:34:34 │ ❱ 93 │ │ await self.simple_r │
2025-01-10 13:34:34 │ 94 │ │
2025-01-10 13:34:34 │ 95 │ def is_allowed_origin(s │
2025-01-10 13:34:34 │ 96 │ │ if self.allow_all_o │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/cors. │
2025-01-10 13:34:34 │ py:144 in simple_response │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 141 │ │
2025-01-10 13:34:34 │ 142 │ async def simple_respon │
2025-01-10 13:34:34 │ request_headers: Headers) - │
2025-01-10 13:34:34 │ 143 │ │ send = functools.pa │
2025-01-10 13:34:34 │ ❱ 144 │ │ await self.app(scop │
2025-01-10 13:34:34 │ 145 │ │
2025-01-10 13:34:34 │ 146 │ async def send(self, me │
2025-01-10 13:34:34 │ None: │
2025-01-10 13:34:34 │ 147 │ │ if message["type"] │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ /usr/local/lib/python3.10/dist-pa │
2025-01-10 13:34:34 │ ckages/starlette/middleware/excep │
2025-01-10 13:34:34 │ tions.py:62 in __call__ │
2025-01-10 13:34:34 │ │
2025-01-10 13:34:34 │ 59 │ │ else: │
2025-01-10 13:34:34 │ 60 │ │ │ conn = WebSocket │
2025-01-10 13:34:34 │ 61 │ │ │
2025-01-10 13:34:34 │ ❱ 62 │ │ await wrap_app_handl │
2025-01-10 13:34:34 │ 63 │ │
2025-01-10 13:34:34 │ 64 │ def http_exception(self, │Source: khoj-ai/khoj