-
Notifications
You must be signed in to change notification settings - Fork 648
Open
Description
During cog predict, a BasePredictor.predict() that returns a list[cog.Path] triggers a TypeError, most likely due to a byte object being passed to urllib.parse.unquote_plus (instead of str).
The underlying Predictor implementation runs fine locally, but fails when called by cog predict.
Tested on python 3.11 and 3.12 with both cog 0.15.9 and 0.16.6.
Full error log:
Traceback (most recent call last):
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py\", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/fastapi/applications.py\", line 1054, in __call__
await super().__call__(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/applications.py\", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/middleware/errors.py\", line 187, in __call__
raise exc
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/middleware/errors.py\", line 165, in __call__
await self.app(scope, receive, _send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/middleware/exceptions.py\", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/_exception_handler.py\", line 53, in wrapped_app
raise exc
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/_exception_handler.py\", line 42, in wrapped_app
await app(scope, receive, sender)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/routing.py\", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/routing.py\", line 734, in app
await route.handle(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/routing.py\", line 288, in handle
await self.app(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/routing.py\", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/_exception_handler.py\", line 53, in wrapped_app
raise exc
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/_exception_handler.py\", line 42, in wrapped_app
await app(scope, receive, sender)
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/starlette/routing.py\", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/fastapi/routing.py\", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/fastapi/routing.py\", line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/cog/server/http.py\", line 385, in predict
return await _predict(
^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/cog/server/http.py\", line 492, in _predict
_ = response_type(**response_object)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/pydantic/main.py\", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/cog/types.py\", line 210, in validate
filename=get_filename(value),
^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/site-packages/cog/types.py\", line 410, in get_filename
basename = urllib.parse.unquote_plus(basename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File \"/root/.pyenv/versions/3.11.13/lib/python3.11/urllib/parse.py\", line 824, in unquote_plus
string = string.replace('+', ' ')
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'str'
Metadata
Metadata
Assignees
Labels
No labels