Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

[Bug]: IMAP Connector fails parsing email sender name containing comma: "Expected a singular address" #13119

@ksufer

Description

@ksufer

Self Checks

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

RAGFlow workspace code commit ID

v0.24.0

RAGFlow image version

v0.24.0

Other environment information

- Hardware parameters: Standard / Not related to this bug
- OS type:Linux (Docker Deployment) Linux homelab 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 14:14:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
- Others: Python 3.12.12 (as seen in logs)

Actual behavior

The IMAP synchronization task crashes with a RuntimeError and stops processing.
The system fails to parse the email header when the sender's display name contains a comma inside double quotes (e.g., "Alessandra Galloni, Reuters Editor-in-Chief"). The parser incorrectly interprets this as multiple addresses instead of a single sender.

Expected behavior

The system should correctly handle quoted strings in email headers containing commas. It should recognize "Name, Title" <[email protected]> as a singular address and proceed with the synchronization without crashing.

Steps to reproduce

1. Configure an IMAP data source (e.g., connecting to QQ Mail).
2. Ensure the inbox contains an email where the sender's name includes a comma, for example:
   `From: "Alessandra Galloni, Reuters Editor-in-Chief" <[email protected]>`
3. Run the synchronization task.
4. The task fails immediately with the "Expected a singular address" error.

Additional information

Error Log:
RuntimeError: Expected a singular address, but instead got multiple; raw_header='"Alessandra Galloni, Reuters Editor-in-Chief" <[email protected]>' addrs=[('', 'Alessandra Galloni'), ('', 'Reuters')]

Location:
/ragflow/common/data_source/imap_connector.py in _parse_singular_addr (line 630)

Traceback highlights:
RuntimeError: Expected a singular address, but instead got multiple; raw_header='"Alessandra Galloni, Reuters Editor-in-Chief" [email protected]' addrs=[('', 'Alessandra Galloni'), ('', 'Reuters')] Traceback (most recent call last): File "/ragflow/rag/svr/sync_data_source.py", line 90, in call await asyncio.wait_for(self._run_task_logic(task), timeout=task["timeout_secs"]) File "/root/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/ragflow/rag/svr/sync_data_source.py", line 121, in _run_task_logic for document_batch in document_batch_generator: ^^^^^^^^^^^^^^^^^^^^^^^^ File "/ragflow/rag/svr/sync_data_source.py", line 988, in wrapper for batch in document_batches(): ^^^^^^^^^^^^^^^^^^ File "/ragflow/rag/svr/sync_data_source.py", line 968, in document_batches for document, failure, next_checkpoint in doc_generator: ^^^^^^^^^^^^^ File "/ragflow/common/data_source/interfaces.py", line 327, in call for document_or_failure in _inner_wrapper(checkpoint_connector_generator): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ragflow/common/data_source/interfaces.py", line 324, in _inner_wrapper self.next_checkpoint = yield from checkpoint_connector_generator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ragflow/common/data_source/imap_connector.py", line 284, in _load_from_checkpoint email_doc = _convert_email_headers_and_body_into_document( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ragflow/common/data_source/imap_connector.py", line 443, in _convert_email_headers_and_body_into_document sender_name, sender_addr = _parse_singular_addr(raw_header=email_headers.sender) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ragflow/common/data_source/imap_connector.py", line 630, in _parse_singular_addr raise RuntimeError( RuntimeError: Expected a singular address, but instead got multiple; raw_header='"Alessandra Galloni, Reuters Editor-in-Chief" [email protected]' addrs=[('', 'Alessandra Galloni'), ('', 'Reuters')]

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working, pull request that fix bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions