Skip to content

[Components] Gmail: Update find-email action to v0.1.2 #17039

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

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

hubertpysklo
Copy link
Contributor

@hubertpysklo hubertpysklo commented Jun 9, 2025

Summary
Adds email header extraction to provide essential email metadata for all messages, improving integration with LLMs and downstream processing.

Changes

  • find-email.mjs
    • Bumped version to 0.1.2
    • Added header extraction for all messages (regardless of withTextPayload setting):
      • message.message_id: Extracted from Message-ID header (now strips <> brackets)
      • message.sender: Extracted from From header
      • message.recipient: Extracted from To header
      • message.subject: Extracted from Subject header
    • Added message.date: Converts internalDate from Unix timestamp to ISO 8601 string format for all messages
  • package.json
    • Bumped version to 0.3.5

Why

  • Enhanced metadata for all messages: Email metadata (sender, recipient, subject, date) is essential context that should be available regardless of whether users want the full payload or simplified text. This makes the action more useful for filtering, sorting, and processing emails.
  • Case-insensitive header matching: Used toLowerCase() for header name comparison since email headers are case-insensitive per RFC specifications, ensuring reliable extraction regardless of how Gmail returns header names.
  • LLM-friendly formatting:
    • Converting Unix timestamps to ISO 8601 strings makes dates human and LLM-readable
    • Stripping <> brackets from Message-ID makes it cleaner for downstream processing
  • Better developer experience: Having consistent metadata available for all messages simplifies workflow development.

How to test
1. Publish the component:

pd publish components/gmail/actions/find-email/find-email.mjs

2. Test with withTextPayload = false:

  • Run the action on various emails
  • Verify that all messages include:
    • message.message_id (without <> brackets)
    • message.sender
    • message.recipient
    • message.subject
    • message.date (in ISO 8601 format)
  • Confirm the original payload structure is preserved

3. Test with withTextPayload = true:

  • Verify the same metadata fields are present
  • Confirm message.payload contains the concatenated plain text

4. Edge cases:

  • Test emails with missing headers (fields should be undefined, no errors)
  • Test emails with headers in different cases (e.g., "message-id" vs "Message-ID")
  • Test with invalid internalDate values
  • Test Message-IDs without <> brackets (should remain unchanged)

Summary by CodeRabbit

  • New Features
    • Enhanced email details display with sender, recipient, subject, and formatted date when plaintext payload is enabled.
  • Chores
    • Updated the version number to 0.1.2 and package version to 0.3.5.

Copy link

vercel bot commented Jun 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jun 12, 2025 8:51pm

Copy link

vercel bot commented Jun 9, 2025

@hubertpysklo is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 9, 2025

Walkthrough

The update increments the version from 0.1.1 to 0.1.2 and refines the Gmail "find-email" action by extracting additional headers ("from", "to", "subject"), formatting the internal date as ISO string, and restructuring payload processing based on the withTextPayload flag for clearer separation of plaintext and raw payload handling.

Changes

File(s) Change Summary
components/gmail/actions/find-email/find-email.mjs Version bump; extract "from", "to", "subject", and ISO-formatted date; restructure payload handling based on withTextPayload flag
components/gmail/package.json Version increment from 0.3.4 to 0.3.5

Poem

A hop and a skip, new headers appear,
From, To, and Subject—now crystal clear!
With dates in ISO, the payload’s in sight,
Rabbits rejoice, for the fields are just right.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/gmail/actions/find-email/find-email.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b3431c and e70a1ed.

📒 Files selected for processing (2)
  • components/gmail/actions/find-email/find-email.mjs (2 hunks)
  • components/gmail/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/gmail/package.json
  • components/gmail/actions/find-email/find-email.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@adolfo-pd adolfo-pd added the User submitted Submitted by a user label Jun 9, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/gmail/actions/find-email/find-email.mjs (1)

64-95: Consider refactoring repetitive header extraction logic.

The header extraction logic is repetitive across multiple blocks. Consider refactoring to improve maintainability:

+      // Helper function to extract header value
+      const getHeaderValue = (headerName) => {
+        const header = message.payload?.headers?.find(
+          (h) => h.name.toLowerCase() === headerName.toLowerCase()
+        );
+        return header?.value;
+      };
+
+      if (this.withTextPayload) {
-        const messageIdHeader = message.payload?.headers?.find(
-          (h) => h.name.toLowerCase() === "message-id",
-        );
-        if (messageIdHeader) {
-          message.message_id = messageIdHeader.value;
-        }
+        const messageId = getHeaderValue("message-id");
+        if (messageId) {
+          message.message_id = messageId;
+        }

         // Add the internal date as a human-readable string
         if (message.internalDate) {
           message.date = new Date(parseInt(message.internalDate)).toISOString();
         }

-        const senderHeader = message.payload?.headers?.find(
-          (h) => h.name.toLowerCase() === "from",
-        );
-        if (senderHeader) {
-          message.sender = senderHeader.value;
-        }
+        const sender = getHeaderValue("from");
+        if (sender) {
+          message.sender = sender;
+        }

-        const recipientHeader = message.payload?.headers?.find(
-          (h) => h.name.toLowerCase() === "to",
-        );
-        if (recipientHeader) {
-          message.recipient = recipientHeader.value;
-        }
+        const recipient = getHeaderValue("to");
+        if (recipient) {
+          message.recipient = recipient;
+        }

-        const subjectHeader = message.payload?.headers?.find(
-          (h) => h.name.toLowerCase() === "subject",
-        );
-        if (subjectHeader) {
-          message.subject = subjectHeader.value;
-        }
+        const subject = getHeaderValue("subject");
+        if (subject) {
+          message.subject = subject;
+        }
       }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75ff31f and 2cc0eaf.

📒 Files selected for processing (1)
  • components/gmail/actions/find-email/find-email.mjs (2 hunks)
🔇 Additional comments (2)
components/gmail/actions/find-email/find-email.mjs (2)

9-9: Version bump looks good.

The version increment from 0.1.1 to 0.1.2 is appropriate for the new functionality being added.


63-96: Conditional header extraction introduces breaking change - ensure proper documentation.

This change introduces a breaking change where message.message_id is no longer extracted when withTextPayload is false. While this aligns with the PR objectives, ensure this is properly documented in release notes and migration guides.

The logic correctly groups metadata extraction with the withTextPayload option and uses case-insensitive header matching as intended.

Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @hubertpysklo thanks for this great contribution! I've just left a minor suggestion and also please increment the version in components/gmail/package.json to "version": "0.3.5",

Right after you changes in your branch you can follow this commands

git add .
git commit --amend --no-edit
git push --force-with-lease origin new-find-email-props

This will update your existing commit rather than adding new ones, keeping the PR history clean.

Thanks again for the contribution!

@jcortes jcortes moved this from In Review to Changes Required in Component (Source and Action) Backlog Jun 10, 2025
@hubertpysklo hubertpysklo force-pushed the new-find-email-props branch 2 times, most recently from 7e11b28 to eef17ee Compare June 10, 2025 23:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🔭 Outside diff range comments (1)
components/gmail/actions/find-email/find-email.mjs (1)

63-68: ⚠️ Potential issue

message.message_id is extracted unconditionally – contradicts stated behavior

PR description says message.message_id should only be added when withTextPayload is true, but the extraction occurs before the flag check, so it runs for every message. Either the doc is wrong or this is an implementation slip.

-      const messageIdHeader = message.payload?.headers?.find(
-        (h) => h.name.toLowerCase() === "message-id",
-      );
-      if (messageIdHeader) {
-        message.message_id = messageIdHeader.value.replace(/[<>]/g, "");
-      }
+      if (this.withTextPayload) {
+        const messageIdHeader = message.payload?.headers?.find(
+          (h) => h.name.toLowerCase() === "message-id",
+        );
+        if (messageIdHeader) {
+          message.message_id = messageIdHeader.value.replace(/[<>]/g, "");
+        }
+      }

Aligning code with the announced breaking-change avoids unexpected field presence for existing consumers.

♻️ Duplicate comments (1)
components/gmail/actions/find-email/find-email.mjs (1)

70-72: ⚠️ Potential issue

Still missing validation for internalDate → potential Invalid Date values
Same issue flagged in earlier review: parseInt(message.internalDate) may yield NaN, producing "Invalid Date" ISO strings.

-      if (message.internalDate) {
-        message.date = new Date(parseInt(message.internalDate)).toISOString();
-      }
+      if (message.internalDate) {
+        const ts = parseInt(message.internalDate, 10);
+        if (!Number.isNaN(ts)) {
+          message.date = new Date(ts).toISOString();
+        }
+      }
🧹 Nitpick comments (1)
components/gmail/actions/find-email/find-email.mjs (1)

60-62: newPayload variable created even when not used – minor cleanup

let newPayload = "" is declared before the withTextPayload check, yet remains unused in the false branch. Declaring it inside the true branch removes a redundant allocation and clarifies intent.

-      let newPayload = "";
-
-      ...
-
-      if (this.withTextPayload) {
-        if (message.payload?.body?.data && !Array.isArray(message.payload.parts)) {
-          const decodedBody = utils.decodeBase64Url(message.payload.body.data);
-          newPayload += convert(decodedBody);
-        }
+      if (this.withTextPayload) {
+        let newPayload = "";
+        if (message.payload?.body?.data && !Array.isArray(message.payload.parts)) {
+          const decodedBody = utils.decodeBase64Url(message.payload.body.data);
+          newPayload += convert(decodedBody);
+        }

Also applies to: 95-106

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cc0eaf and eef17ee.

📒 Files selected for processing (2)
  • components/gmail/actions/find-email/find-email.mjs (2 hunks)
  • components/gmail/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/gmail/package.json

@hubertpysklo hubertpysklo requested a review from jcortes June 11, 2025 00:02
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @hubertpysklo lgtm! Ready for QA!

@jcortes jcortes moved this from Changes Required to Ready for QA in Component (Source and Action) Backlog Jun 11, 2025
@vunguyenhung vunguyenhung moved this from Ready for QA to Ready for Release in Component (Source and Action) Backlog Jun 12, 2025
@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test report
https://vunguyenhung.notion.site/Components-Gmail-Update-find-email-action-to-v0-1-2-20fbf548bb5e81c6b3acdeeba737cf38

@jcortes jcortes force-pushed the new-find-email-props branch from eef17ee to 6b3431c Compare June 12, 2025 20:41
@jcortes
Copy link
Collaborator

jcortes commented Jun 12, 2025

/approve

@jcortes jcortes force-pushed the new-find-email-props branch from 6b3431c to e70a1ed Compare June 12, 2025 20:50
@jcortes jcortes merged commit 3d4d24e into PipedreamHQ:master Jun 12, 2025
10 of 11 checks passed
@github-project-automation github-project-automation bot moved this from Ready for Release to Done in Component (Source and Action) Backlog Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User submitted Submitted by a user
Development

Successfully merging this pull request may close these issues.

5 participants