Skip to content

IMAP 'faulty continuation request' causes nil response and sync failures #362

@ooogogoo

Description

@ooogogoo

🐛 Bug Description

msgvault fails to sync certain IMAP emails with failed to fetch message (nil response) errors. The root cause appears to be an IMAP protocol parsing issue when the server returns a "faulty continuation request".

Environment

  • msgvault version: v0.15.0
  • commit: e7e8593
  • built: 2026-05-29T00:16:55Z
  • go: go1.26.3
  • os/arch: linux/amd64
  • IMAP server: Tencent Exmail (exmail.qq.com)

Error Logs

time=2026-06-01T17:03:19.990+08:00 level=WARN msg="failed to fetch message (nil response)" run_id=9379eaae2e44 id=INBOX|914

IMAP codec warnings:

WARN imap_codec::response: Rectified faulty continuation request `+ ` to `+ ... `
WARN imap_codec::response: Rectified missing `text` to "..."

Impact

  • Total emails affected: 261 emails
  • Sync success rate: 87.5% (1,835/2,096 emails synced)
  • Data integrity: 99.3% (by folder count)

Investigation Results

  1. ✅ Emails DO exist on the IMAP server (verified with himalaya CLI)
  2. ❌ msgvault's IMAP parser cannot handle the server's response format
  3. ❌ Retrying with exponential backoff (5 attempts) produces the same errors
  4. ❌ The 261 affected emails have identical error patterns across all retry attempts

Reproduction Steps

  1. Configure msgvault with an IMAP account (Tencent Exmail/exmail.qq.com)
  2. Run msgvault sync
  3. Observe failed to fetch message (nil response) errors for specific email IDs

Affected Email IDs (sample)

INBOX|914, INBOX|916, INBOX|918, INBOX|920, INBOX|921, INBOX|922, INBOX|925, INBOX|927, INBOX|934, INBOX|1029... (261 total, see attached list)

Expected Behavior

msgvault should either:

  1. Successfully sync these emails despite the server's non-standard IMAP response
  2. Provide a clearer error message indicating the IMAP protocol parsing issue
  3. Allow manual retry of specific failed email IDs

Possible Cause

The imap_codec library (used by msgvault) is detecting and "rectifying" faulty continuation requests from the server, but the higher-level msgvault sync logic is not handling this gracefully, resulting in nil response errors.

Workaround

Users can access these emails via alternative IMAP clients (e.g., himalaya, Thunderbird) that handle the server's response format correctly.

Attachments

  • Full error log: Available upon request
  • List of affected email IDs: 261 emails in INBOX folder

Priority: Medium-High (affects ~12.5% of emails in affected accounts)
Label: bug, imap, sync-failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions