fix: Enhance Gmail API Component with Field Extraction, Add Flow Locking, and Improve Test Stability (#7864)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-04-30 15:21:28 -03:00 committed by GitHub
commit cf5dba11df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 228 additions and 215 deletions

View file

@ -80,6 +80,8 @@ class ComposioGmailAPIComponent(ComposioBaseComponent):
"GMAIL_LIST_THREADS": {
"display_name": "List Email Threads",
"action_fields": ["max_results", "query", "gmail_user_id", "page_token"],
"get_result_field": True,
"result_field": "threads",
},
"GMAIL_REPLY_TO_THREAD": {
"display_name": "Reply To Thread",
@ -88,6 +90,8 @@ class ComposioGmailAPIComponent(ComposioBaseComponent):
"GMAIL_LIST_LABELS": {
"display_name": "List Email Labels",
"action_fields": ["gmail_user_id"],
"get_result_field": True,
"result_field": "labels",
},
"GMAIL_CREATE_LABEL": {
"display_name": "Create Email Label",
@ -96,6 +100,8 @@ class ComposioGmailAPIComponent(ComposioBaseComponent):
"GMAIL_GET_PEOPLE": {
"display_name": "Get Contacts",
"action_fields": ["resource_name", "person_fields"],
"get_result_field": True,
"result_field": "people_data",
},
"GMAIL_REMOVE_LABEL": {
"display_name": "Delete Email Label",
@ -374,12 +380,13 @@ class ComposioGmailAPIComponent(ComposioBaseComponent):
"status": error_data.get("status"),
}
result_data = result.get("data", [])
if (
len(result_data) != 1
and not self._actions_data.get(action_key, {}).get("result_field")
and self._actions_data.get(action_key, {}).get("get_result_field")
):
result_data = result.get("data", {})
actions_data = self._actions_data.get(action_key, {})
# If 'get_result_field' is True and 'result_field' is specified, extract the data
# using 'result_field'. Otherwise, fall back to the entire 'data' field in the response.
if actions_data.get("get_result_field") and actions_data.get("result_field"):
result_data = result_data.get(actions_data.get("result_field"), result.get("data", []))
if len(result_data) != 1 and not actions_data.get("result_field") and actions_data.get("get_result_field"):
msg = f"Expected a dict with a single key, got {len(result_data)} keys: {result_data.keys()}"
raise ValueError(msg)
return result_data # noqa: TRY300

View file

@ -261,6 +261,7 @@ class FlowUpdate(SQLModel):
folder_id: UUID | None = None
endpoint_name: str | None = None
mcp_enabled: bool | None = None
locked: bool | None = None
action_name: str | None = None
action_description: str | None = None
access_type: AccessTypeEnum | None = None