2022-12-14 12:02:12,292 ???? thumbor:ERROR TypeError: write() argument must be str, not bytes 2022-12-14 12:02:12,292 ???? thumbor:ERROR ERROR: Traceback (most recent call last): File "/opt/lib/python/site-packages/thumbor/handlers/__init__.py", line 212, in get_image result = await self._fetch(self.context.request.image_url) File "/opt/lib/python/site-packages/thumbor/handlers/__init__.py", line 876, in _fetch raise fetch_result.exception File "/opt/lib/python/site-packages/thumbor/handlers/__init__.py", line 844, in _fetch self.context.request.engine.load(fetch_result.buffer, extension) File "/srv/service/wikimedia_thumbor/engine/proxy/proxy.py", line 125, in load self.lcl[enginename].load(buffer, extension) File "/opt/lib/python/site-packages/thumbor/engines/__init__.py", line 195, in load image_or_frames = self.create_image(buffer) File "/srv/service/wikimedia_thumbor/engine/svg/svg.py", line 41, in create_image self.prepare_source(buffer) File "/srv/service/wikimedia_thumbor/engine/__init__.py", line 56, in prepare_source source.write(buffer) TypeError: write() argument must be str, not bytes
Description
Description
Details
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Fix TypeError of SVG conversion | operations/software/thumbor-plugins | master | +1 -1 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
In Progress | Goal | • DAbad | T300754 <Future Planning> Commons Support Needs | ||
In Progress | • DAbad | T294484 <Code Stewardship Review> Thumbor | |||
Restricted Task | |||||
Resolved | hnowlan | T233196 Migrate thumbor to Kubernetes | |||
Resolved | Vlad.shapik | T325150 byte/str TypeError during svg conversion |
Event Timeline
Comment Actions
Change 868456 had a related patch set uploaded (by Vlad.shapik; author: Vlad.shapik):
[operations/software/thumbor-plugins@master] Fix TypeError of SVG conversion
Comment Actions
It seems that I found where is the trick. As it turned out the failed SVG file has a small body, as a result, the source in the prepare_source function can be created from a buffer and the buffer is a byte string. So it requires opening a file to write bytes.
Other files I took to test this bug have a bigger body, so the source was taken from the context and there is no need to create a temporary file and write to this file in the prepare_source function.
Comment Actions
Change 868456 merged by jenkins-bot:
[operations/software/thumbor-plugins@master] Fix TypeError of SVG conversion