feat(integrations): Gmail UDFs for email automation#1777
Merged
topher-lo merged 5 commits intoTracecatHQ:mainfrom Dec 22, 2025
Merged
feat(integrations): Gmail UDFs for email automation#1777topher-lo merged 5 commits intoTracecatHQ:mainfrom
topher-lo merged 5 commits intoTracecatHQ:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/tracecat-registry/tracecat_registry/integrations/gmail.py">
<violation number="1" location="packages/tracecat-registry/tracecat_registry/integrations/gmail.py:85">
P2: Silent failure when fetching individual message metadata. Non-200 responses are silently ignored, which could lead to confusing partial results without any indication that some messages failed to fetch. Consider logging failed fetches or including error info in the response.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
packages/tracecat-registry/tracecat_registry/integrations/gmail.py
Outdated
Show resolved
Hide resolved
topher-lo
requested changes
Dec 21, 2025
packages/tracecat-registry/tracecat_registry/integrations/gmail.py
Outdated
Show resolved
Hide resolved
topher-lo
requested changes
Dec 21, 2025
| results = [] | ||
| for msg in messages: | ||
| msg_id = msg['id'] | ||
| msg_response = await client.get( |
Contributor
There was a problem hiding this comment.
We generally prefer to be a very thin wrapper around the API themselves (to avoid losing context). Can we just return the original data as opposed to change the schema?
| params={"format": "full"}, | ||
| ) | ||
| response.raise_for_status() | ||
| msg_data = response.json() |
Contributor
There was a problem hiding this comment.
Same comment as above? Can we just return the msg_data directly?
| params={"format": "metadata"}, | ||
| ) | ||
| response.raise_for_status() | ||
| msg_data = response.json() |
| messages = [] | ||
| for msg in thread_data.get("messages", []): | ||
| headers = {h["name"]: h["value"] for h in msg.get("payload", {}).get("headers", [])} | ||
| messages.append({ |
- Add docstring for OAuth secret with setup instructions - Return full API response instead of manipulating schema - Remove all custom response formats - just return response.json() - Add configurable 'format' parameter for message/thread requests - Add 'metadata_headers' parameter for header filtering - Add page_token support for search pagination - Add get_attachment function for downloading attachments
topher-lo
approved these changes
Dec 22, 2025
Signed-off-by: Chris Lo <46541035+topher-lo@users.noreply.github.com>
topher-lo
approved these changes
Dec 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
uv run pytest tests)?pre-commit run --all-files)?Description
This PR adds Gmail UDFs (User Defined Functions) for email security automation workflows.
Functions Included
search_messages- Search Gmail with query syntaxget_message- Get full message contentget_message_headers- Get headers only (faster)list_labels- List Gmail labelsget_thread- Get full email threadget_connected_account- Show connected Gmail accountFeatures
google_gmailprovider)Use Cases
Related Issues
Companion PR for Gmail OAuth provider: #[PR_NUMBER_FROM_PR1]
Screenshots / Recordings
The Gmail UDFs will appear in the workflow builder under the "Gmail" display group. Users can:
Steps to QA
Prerequisites
Testing
from:test@example.com)Example Queries
from:suspicious@evil.com has:attachment- Find emails with attachments from sendersubject:urgent after:2024/01/01- Find urgent emails after dateis:unread label:inbox- Find unread emails in inboxhas:attachment filename:pdf- Find emails with PDF attachmentsNote: Requires companion OAuth provider PR to be merged first for full functionality.
Summary by cubic
Adds Gmail UDFs for security automation. Workflows can search emails, fetch full messages or headers, get threads, list labels, and download attachments using the Tracecat Gmail OAuth.
New Features
Migration
Written for commit db7608f. Summary will update automatically on new commits.