- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Add metadataOnly to gmail-find-email action #18435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
 | 
| WalkthroughUpdates gmail-find-email action: adds boolean prop metadataOnly, changes maxResults default from 100 to 20 and updates descriptions, and bumps action version to 0.1.6. Runtime now conditionally strips message.payload and message.snippet when metadataOnly is true. Package version in components/gmail/package.json bumped to 1.3.2. Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  participant C as Client
  participant A as gmail-find-email Action
  participant G as Gmail API
  C->>A: run(query, maxResults, metadataOnly)
  A->>G: messages.list(query, maxResults=20 default)
  G-->>A: message IDs
  A->>G: messages.get(each ID)
  G-->>A: message objects
  alt metadataOnly == true
    A->>A: Remove message.payload and message.snippet
    note right of A: Emit metadata-only results
  else metadataOnly == false
    A->>A: validateTextPayload(message)
    A->>A: Process text payload/snippet as before
  end
  A-->>C: Results array
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
 Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
 ✅ Passed checks (3 passed)
 ✨ Finishing touches
 🧪 Generate unit tests
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️  Outside diff range comments (1)
components/gmail/actions/find-email/find-email.mjs (1)
65-107: Bug: Emitted array may exclude parsed payload changes when validateTextPayload returns a new object.You push the message before potential reassignment (message = parsedMessage). If validateTextPayload returns a new object, messagesToEmit holds the original object, not the parsed one.
Apply this diff to push after processing and preserve derived fields when parsedMessage is returned:
@@ - const messagesToEmit = []; - for await (let message of this.gmail.getAllMessages(messageIds)) { - messagesToEmit.push(message); + const messagesToEmit = []; + for await (let message of this.gmail.getAllMessages(messageIds)) { @@ - if (this.metadataOnly) { - delete message.payload; - delete message.snippet; - } else { - const parsedMessage = utils.validateTextPayload(message, this.withTextPayload); - if (parsedMessage) { - message = parsedMessage; - } else { - if (message.payload?.body?.data && !Array.isArray(message.payload.parts)) { - message.payload.body.text = utils.decodeBase64Url(message.payload.body.data); - } - if (Array.isArray(message.payload?.parts)) { - utils.attachTextToParts(message.payload.parts); - } - } - } + if (this.metadataOnly) { + delete message.payload; + delete message.snippet; + messagesToEmit.push(message); + } else { + const parsedMessage = utils.validateTextPayload(message, this.withTextPayload); + if (parsedMessage) { + const { message_id, date, sender, recipient, subject } = message; + message = { + ...parsedMessage, + message_id, + date, + sender, + recipient, + subject, + }; + } else { + if (message.payload?.body?.data && !Array.isArray(message.payload.parts)) { + message.payload.body.text = utils.decodeBase64Url(message.payload.body.data); + } + if (Array.isArray(message.payload?.parts)) { + utils.attachTextToParts(message.payload.parts); + } + } + messagesToEmit.push(message); + }
🧹 Nitpick comments (4)
components/gmail/actions/find-email/find-email.mjs (4)
24-30: Tighten copy; clarify interplay with withTextPayload and define “metadata.”Current text is missing “to” and doesn’t state that withTextPayload is ignored when metadataOnly=true. Define metadata explicitly per issue #18426.
metadataOnly: { type: "boolean", label: "Metadata Only", - description: "Only return metadata for the messages. This reduces the size of the payload and makes it easier for LLMs work with.", + description: "Return only message metadata (all fields except `snippet` and `payload`). This reduces the payload size and makes it easier for LLMs to work with. When enabled, the “Return payload as plaintext” option is ignored.", optional: true, default: false, },Also consider updating withTextPayload’s description to note it’s ignored when Metadata Only is enabled.
19-23: Copy nit: missing “to.”“… makes it easier for LLMs work with” → “… makes it easier for LLMs to work with.”
- description: "Convert the payload response into a single text field. **This reduces the size of the payload and makes it easier for LLMs work with.**", + description: "Convert the payload response into a single text field. This reduces the size of the payload and makes it easier for LLMs to work with.",
100-114: Minor: fast‑path return in metadataOnly branch.You can push and continue to next iteration after deleting content, avoiding unnecessary checks.
- if (this.metadataOnly) { + if (this.metadataOnly) { delete message.payload; delete message.snippet; + messagesToEmit.push(message); + continue; } else {
1-124: Use the processed message when adding to messagesToEmit (components/gmail/actions/find-email/find-email.mjs)
messagesToEmit.push(message) is called before utils.validateTextPayload; move the push after parsing or push parsedMessage || message so emission doesn't rely on in-place mutation. Other call sites (components/gmail/sources/new-attachment-received/new-attachment-received.mjs and components/gmail/sources/common/base.mjs) already use the returned parsedMessage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
- components/gmail/actions/find-email/find-email.mjs(4 hunks)
- components/gmail/package.json(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/gmail/actions/find-email/find-email.mjs (3)
components/gmail/sources/new-email-received/new-email-received.mjs (1)
message(587-589)components/gmail/sources/common/base.mjs (2)
message(24-28)
parsedMessage(21-21)components/gmail/sources/new-attachment-received/new-attachment-received.mjs (1)
parsedMessage(105-105)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
- GitHub Check: Publish TypeScript components
- GitHub Check: pnpm publish
🔇 Additional comments (3)
components/gmail/package.json (1)
3-3: Version bump looks correct; confirm release notes and publish flow.1.3.2 aligns with the new action behavior. Ensure CHANGELOG/release notes reflect the default change for maxResults and the new metadataOnly prop before publishing.
components/gmail/actions/find-email/find-email.mjs (2)
8-8: Version bump to 0.1.6 is appropriate.Good granularity for the added prop and default change.
51-53: Default change from 100 → 20: confirm impact and comms.This is a behavior change that may reduce results for existing users who didn’t set maxResults. Ensure docs/release notes call this out, and consider a deprecation note if existing workflows auto‑upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michelle0927, LGTM! Ready for QA!
Resolves #18426
Summary by CodeRabbit