kiwitcms / Kiwi

open source test management system with over 2 million downloads!
https://kiwitcms.org
GNU General Public License v2.0
987 stars 295 forks source link

Problem with uploading screenshots #3756

Open StefanPajovic opened 2 months ago

StefanPajovic commented 2 months ago

Hello,

I have an issue when uploading screenshots for my tests in Kiwi TCMS. Namely, when I try to upload a photo during a test run, I sometimes get the reply: Internal error: {'attachment_file': ['File contains forbidden tag: ']} (see screenshot):

Kiwi error

I cannot provide you more info regarding this bug because there is no exact environment it happens in. I am always trying to upload screenshots (no HTML or anything similar) that are named in Latin characters. They also contain commas and full stops but that shouldn't be a problem. When this bug occured, I tried restarting Kiwi but it didn't help; as if the screenshot had some tag that made it unuploadable to Kiwi. I try then making the exact same screenshot and naming it exactly the same as the problematic one. This works, as it instantly uploads.

My dev team directed me to you to try and find a solution: have you encountered similar bugs and is there any way to resolve them? I would like to add that this issue used to occur up a month ago. Before that, it happened on average to every tenth picture I tried to upload.

Thank you in advance for all your help. :)

lmoellendorf commented 2 months ago

I have the same issue

This is the log if a png is uploaded in the test case editor:

[-32603] Internal error: {'attachment_file': ['File contains forbidden tag: <xmp>']}
Traceback (most recent call last):
  File "/venv/lib64/python3.11/site-packages/modernrpc/core.py", line 143, in execute
    return self.function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/tcms/rpc/api/user.py", line 185, in add_attachment
    utils.add_attachment(
  File "/venv/lib64/python3.11/site-packages/tcms/rpc/utils.py", line 103, in add_attachment
    raise ValueError(errors)
ValueError: {'attachment_file': ['File contains forbidden tag: <xmp>']}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/venv/lib64/python3.11/site-packages/modernrpc/handlers/jsonhandler.py", line 182, in process_single_request
    result_data = _method.execute(context, args, kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/modernrpc/core.py", line 151, in execute
    raise RPCInternalError(str(exc)) from exc
modernrpc.exceptions.RPCInternalError: [-32603] Internal error: {'attachment_file': ['File contains forbidden tag: <xmp>']}
172.31.0.1 - - [03/Sep/2024:17:29:24 +0000] "POST /json-rpc/ HTTP/1.0" 200 152 "https://tcms.pe.loc/case/7/edit/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" "-"
[pid: 1170291|app: 0|req: 100959/200102] 172.31.0.1 () {62 vars in 1041 bytes} [Tue Sep  3 17:29:24 2024] POST /json-rpc/ => generated 152 bytes in 25 msecs (HTTP/1.0 200) 8 headers in 252 bytes (2 switches on core 0)

If a jpg is uploaded instead, the error changes to:

[-32603] Internal error: {'attachment_file': ['File contains forbidden tag: <rt>']}

It started after updating to v13.3 from a very old version (presumably 11.2).

It may be related to tcms.kiwi_attachments.validators as indicated in #3349.