This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
MosaicTilerFactory UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 8: invalid continuation byte #686
Labels
bug
Something isn't working
Problem description
Here is my code,
from titiler.mosaic.factory import MosaicTilerFactory
mosaic = MosaicTilerFactory(router_prefix="apptilemosaic")
app.include_router(mosaic.router,prefix='/apptilemosaic')
however, it threw
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 375, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/debug.py", line 96, in call
raise exc from None
File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/debug.py", line 93, in call
await self.app(scope, receive, inner_send)
File "/usr/local/lib/python3.8/dist-packages/fastapi/applications.py", line 199, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 181, in call
raise exc from None
File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/cors.py", line 78, in call
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/base.py", line 25, in call
response = await self.dispatch_func(request, self.call_next)
File "/root/code/main.py", line 32, in add_process_time_header
response = await call_next(request)
File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/base.py", line 45, in call_next
task.result()
File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/base.py", line 38, in coro
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 82, in call
raise exc from None
File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 580, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 241, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 52, in app
response = await func(request)
File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 201, in app
raw_response = await run_endpoint_function(
File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 150, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/usr/local/lib/python3.8/dist-packages/starlette/concurrency.py", line 40, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.8/dist-packages/titiler/mosaic/factory.py", line 124, in info
with self.reader(src_path, **self.backend_options) as src_dst:
File "/usr/local/lib/python3.8/dist-packages/cogeo_mosaic/backends/init.py", line 47, in MosaicBackend
return HttpBackend(url, *args, **kwargs)
File "", line 12, in init
self.attrs_post_init()
File "/usr/local/lib/python3.8/dist-packages/cogeo_mosaic/backends/web.py", line 34, in attrs_post_init
self.mosaic_def = self._read()
File "/usr/local/lib/python3.8/dist-packages/cachetools/init.py", line 737, in wrapper
v = func(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/cogeo_mosaic/backends/web.py", line 64, in _read
return MosaicJSON(**json.loads(body))
File "/usr/lib/python3.8/json/init.py", line 343, in loads
s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 8: invalid continuation byte
[this should explain why the current behavior is a problem and why the expected output is a better solution.]
Expected Output
Environment Information
Os, Python version, ...
Linux version 5.10.16.3-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Apr 2 22:23:49 UTC 2021
The text was updated successfully, but these errors were encountered: