From 15bcff77a191aac7a00fd696a0c4d8ff8a6a0e6d Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sun, 31 May 2026 15:40:17 +0200 Subject: [PATCH] Fix search_list rendering "undefined" email fields when quick=true Fixes #9. In quick mode, PonyMail's /api/stats.lua returns email objects without subject/from/id, so the emails section rendered each entry as "- **undefined** From: undefined | ID: undefined". Quick mode is documented as stats-only (emails_only exists for email summaries), so skip the emails section entirely when quick=true. The subject/from/id fields are also guarded with fallbacks so a sparse entry never renders as "undefined". Verified live against dev@iceberg.apache.org (the reported repro): quick=true now returns stats only; emails_only=true still renders populated subjects, senders, and IDs. Generated-by: Claude Code 2.1.158 (Claude Opus 4.8) --- mcp/ponymail-mcp/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mcp/ponymail-mcp/index.js b/mcp/ponymail-mcp/index.js index acb4a78..b1fe782 100644 --- a/mcp/ponymail-mcp/index.js +++ b/mcp/ponymail-mcp/index.js @@ -272,8 +272,11 @@ server.tool( lines.push(""); } - // Emails - if (data.emails) { + // Emails — `quick` mode is stats-only: PonyMail's quick response carries + // email objects without subject/from/id (issue #9), so skip the section + // entirely. Use `emails_only` to get email summaries. Fields are also + // guarded below so a sparse entry never renders as "undefined". + if (!quick && data.emails) { lines.push("## Emails"); const emails = Array.isArray(data.emails) ? data.emails @@ -284,8 +287,8 @@ server.tool( const windowed = emails.slice(start, end); for (const e of windowed) { const date = e.date || new Date((e.epoch || 0) * 1000).toISOString().slice(0, 10); - lines.push(`- **${e.subject}**`); - lines.push(` From: ${e.from} | Date: ${date} | ID: ${e.id || e.mid}`); + lines.push(`- **${e.subject || "(no subject)"}**`); + lines.push(` From: ${e.from || "(unknown sender)"} | Date: ${date} | ID: ${e.id || e.mid || "(no id)"}`); } lines.push(""); if (total === 0) {