Skip to content

fix(memory): tolerate folded and invalid Date headers in email import - #3297

Open
Chen Yufeiyang (feiiiiii5) wants to merge 1 commit into
microsoft:mainfrom
feiiiiii5:fix/1129-TypeAgent-r1
Open

Chen Yufeiyang (feiiiiii5) wants to merge 1 commit into
microsoft:mainfrom
feiiiiii5:fix/1129-TypeAgent-r1

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Problem

importEmailFromMimeText, used by importEmlFile and loadEmailMessagesFromDir, passed the raw Date: header to a strict source-date parser. A malformed header threw TemporalValueError and aborted the whole file (or directory) import; a folded RFC 5322 header left an embedded newline in sentOnRaw and in the stored temporal messageTime.raw shown as evidence.

Root cause

The header value was neither unfolded nor validated before parsing. mailparser synthesizes a date for malformed headers, but that is not the sender's stated date, so it must not be adopted silently.

Fix

Unfold continuation whitespace, parse once, and only keep sentOnRaw when parsing succeeds. Unparseable headers leave sentOn and sentOnRaw unset instead of failing the import.

Verification

  • Regression spec on the base source: 2 failed / 5 passed with TemporalValueError; with the fix 7/7 pass.
  • @typeagent/conversation-memory local suite: 55/55 across 6 suites.
  • tsc -b and Prettier clean on changed files.

Not verified: live LLM/network calls, full workspace CI, other import formats, or Windows line-ending behavior beyond \r?\n.

AI-assisted development. Human review requested before merge.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant