Skip to content

Fix email threads#175

Open
cooper-grc wants to merge 2 commits intomainfrom
cg/email-threads
Open

Fix email threads#175
cooper-grc wants to merge 2 commits intomainfrom
cg/email-threads

Conversation

@cooper-grc
Copy link
Copy Markdown
Contributor

@cooper-grc cooper-grc commented Apr 1, 2026

Summary by cubic

Fixes Gmail threading by adding proper In-Reply-To and References headers on replies and drafts using Message-ID values from the target thread, and sanitizes reply headers to prevent injection. Emails still send if header fetch fails.

  • Bug Fixes
    • Added getThreadReplyHeaders to fetch Message-IDs from /threads/{id} and pass them to buildRawEmail.
    • Updated createDraft and sendEmail to include reply headers when thread_id is provided; graceful fallback on fetch errors.
    • Sanitized In-Reply-To and References in buildRawEmail; added tests for header inclusion, 404 fallback, and injection sanitization in pkg/tools/clients.

Written for commit 1e4a3d9. Summary will update on new commits.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

✅ Integration Tests PASSED

Gateway: https://api.airstore.ai
Query path: /sources/gmail/unread-emails
Timestamp: 2026-04-01T01:39:34Z

I/O Smoke Tests

Test Status Latency Bytes
list_sources PASS 372ms -
list_gmail PASS 326ms -
list_query_path PASS 648ms -
read_file PASS 449ms 493
stat_file PASS 302ms 6,898

Compression A/B Tests

Metric Value
Files tested 10
Total raw bytes 75,219
Total strip bytes 48,466
Total raw tokens 42,483
Total strip tokens 28,269
Tokens saved 14,214
Byte reduction 35%
Token reduction 33%
Min threshold 10%
Cache consistent Yes
Per-file results
File Raw B Strip B Raw Tok Strip Tok Tok Saved Red% Raw ms Strip ms
2026-03-31_eli_Laundromat_Use_Inquiry... 493 492 159 159 0 0% 318ms 292ms
2024-10-15_Harris-Walz_Organizing_Tea... 2,337 2,305 976 967 9 1% 417ms 310ms
2024-10-15_Stephen_King_via_KamalaHar... 2,904 2,866 1,116 1,103 13 1% 447ms 301ms
2026-04-01_VS_News_Network_Final_Remi... 1,693 1,644 595 580 15 2% 447ms 303ms
2025-07-17_KAYAK_How_to_have_everythi... 1,724 1,670 1,220 1,204 16 3% 455ms 322ms
2025-07-17_Alamo_Drafthouse_Cinema_Th... 19,047 18,224 12,228 11,704 524 4% 524ms 375ms
2025-07-17_Alamo_Drafthouse_Cinema_Th... 18,978 18,155 12,105 11,578 527 4% 521ms 419ms
2024-10-15_Knut_at_Sanity_Join_us_tom... 1,272 726 504 209 295 42% 449ms 303ms
2025-07-17_Lindsay_Stanley_TODAY_Conf... 1,876 1,049 657 268 389 44% 442ms 298ms
2025-07-17_NORDSTROM_RACK_FLASH_Travi... 24,895 1,335 12,923 497 12,426 94% 508ms 320ms

Charts

Overall Compression
Raw vs Compressed Bytes
Token Comparison
Reduction by File
Read Latency
I/O Latency

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="pkg/tools/clients/gmail.go">

<violation number="1" location="pkg/tools/clients/gmail.go:498">
P2: Sanitize `In-Reply-To` and `References` before writing them into raw headers to prevent header injection via unexpected CR/LF characters.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

@cooper-grc cooper-grc requested a review from luke-lombardi April 1, 2026 01:42
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