ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Bug]:Exceed the maximum length of file name

Open Simonqujian78 opened this issue 7 months ago • 8 comments

Self Checks

  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (Language Policy).
  • [x] Non-english title submitions will be closed directly ( 非英文标题的提交将会被直接关闭 ) (Language Policy).
  • [x] Please do not modify this template :) and fill in all the required fields.

RAGFlow workspace code commit ID

No found related issues.

RAGFlow image version

v0.18.0-137-g36e32dde slim

Other environment information

win11+docker4.41.2+lm studio 0.3.15+ragflow:nightly.

Actual behavior

I want to add a new file in my "Knowledge database", the filename is "938--国家金融监督管理总局办公厅关于规范总局系统行政检查工作的通知(金办发〔2025〕45号)", but a error information " Exceed the maximum length of file name!" .

Image

It is the first time for me to encounter the error information.I also uploaded many files whose length of filenames is longer than "938"

Expected behavior

I wonder how to revise the maximum length of the filename.

Steps to reproduce

Just upload the file, click"OK".

Additional information

No response

Simonqujian78 avatar May 18 '25 07:05 Simonqujian78

To revise the maximum length of a filename in RAGFlow, you need to modify the NAME_LENGTH_LIMIT constant in the api/constants.py file. The current limit is set to 2 ** 10, which is 1024. You can change this value to your desired limit. For example, to set the limit to 512, you would update the line as follows:

NAME_LENGTH_LIMIT = 512

This change will allow you to upload files with longer names without encountering the error message [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 18 '25 07:05 dosubot[bot]

@dosu, thanks for your reply. As your said , the maximum length of filename is 1024, the filename I uploaded is "938--国家金融监督管理总局办公厅关于规范总局系统行政检查工作的通知(金办发〔2025〕45号)", it is obvious that the length of the filename is smaller than 1024, so maybe it is a bug.

Simonqujian78 avatar May 18 '25 09:05 Simonqujian78

The error message is likely not a bug. The filename length is checked in bytes, not characters. If your filename contains multi-byte characters, such as Chinese characters, it could exceed the 128-byte limit when encoded in UTF-8, even if the character count is less than 1024 [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 18 '25 09:05 dosubot[bot]

OK, understand, 128-byte is the limit of the length of filename. If I revise NAME_LENGTH_LIMIT = 2**11 in constants.py file, the limit will be also revised 256-byte?

Simonqujian78 avatar May 18 '25 11:05 Simonqujian78

OK, understand, 128-byte is the limit of the length of filename. If I revise NAME_LENGTH_LIMIT = 2**11 in constants.py file, the limit will be also revised 256-byte?

Hi @Simonqujian78, based on my experience, this config is not in the config file. if len(file.filename.encode("utf-8")) >= 128: raise RuntimeError("Exceed the maximum length of file name!")

Woody-Hu avatar May 19 '25 00:05 Woody-Hu

That is to say no way to revise the limitition?

OK, understand, 128-byte is the limit of the length of filename. If I revise NAME_LENGTH_LIMIT = 2**11 in constants.py file, the limit will be also revised 256-byte?

Hi @Simonqujian78, based on my experience, this config is not in the config file. if len(file.filename.encode("utf-8")) >= 128: raise RuntimeError("Exceed the maximum length of file name!")

Simonqujian78 avatar May 19 '25 01:05 Simonqujian78

That is to say no way to revise the limitition?

OK, understand, 128-byte is the limit of the length of filename. If I revise NAME_LENGTH_LIMIT = 2**11 in constants.py file, the limit will be also revised 256-byte?

Hi @Simonqujian78, based on my experience, this config is not in the config file. if len(file.filename.encode("utf-8")) >= 128: raise RuntimeError("Exceed the maximum length of file name!")

For now should be just modify the code, but I think your requirement is makesense, so I create a PR for this.

Woody-Hu avatar May 19 '25 04:05 Woody-Hu

That is to say no way to revise the limitition?

OK, understand, 128-byte is the limit of the length of filename. If I revise NAME_LENGTH_LIMIT = 2**11 in constants.py file, the limit will be also revised 256-byte?

Hi @Simonqujian78, based on my experience, this config is not in the config file. if len(file.filename.encode("utf-8")) >= 128: raise RuntimeError("Exceed the maximum length of file name!")

For now should be just modify the code, but I think your requirement is makesense, so I create a PR for this.

Great!! Thanks.

Simonqujian78 avatar May 19 '25 12:05 Simonqujian78