Skip to content

fix: Composio base to handle dataframe response correctly#9427

Merged
edwinjosechittilappilly merged 4 commits into
langflow-ai:mainfrom
ComposioHQ:feat-composio-v3-2-hotfix1
Aug 22, 2025
Merged

fix: Composio base to handle dataframe response correctly#9427
edwinjosechittilappilly merged 4 commits into
langflow-ai:mainfrom
ComposioHQ:feat-composio-v3-2-hotfix1

Conversation

@Uday-sidagana
Copy link
Copy Markdown
Contributor

@Uday-sidagana Uday-sidagana commented Aug 18, 2025

Fixed output Dataframe handling in /src/backend/base/langflow/base/composio/composio_base.py

Summary by CodeRabbit

  • New Features

    • Introduced app-scoped “Status” field (shown as “ Status”) to avoid naming conflicts across integrations.
    • Updated field descriptions to clarify the app context for status.
  • Bug Fixes

    • Ensured actions using “ Status” execute correctly by mapping to the expected backend parameter.
    • Improved robustness when generating data tables, preventing issues when a column is named “data” and reducing potential crashes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 18, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Aug 18, 2025
Copy link
Copy Markdown
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 (2)
src/backend/base/langflow/base/composio/composio_base.py (2)

138-146: Defensive rename is good; add a small guard for non-pandas DataFrame types

Renaming a "data" column to avoid attribute collisions is sensible. To harden this, also guard on the presence of a rename method so custom DataFrame implementations without pandas-like API don’t trigger the try/except path unnecessarily.

-        if hasattr(result_dataframe, "columns"):
+        if hasattr(result_dataframe, "columns") and hasattr(result_dataframe, "rename"):
             try:
                 if "data" in result_dataframe.columns:
                     result_dataframe = result_dataframe.rename(columns={"data": "_data"})
             except (AttributeError, TypeError, ValueError, KeyError) as e:
                 logger.debug(f"Failed to rename 'data' column: {e}")

1261-1262: Good: maps aliased '_status' back to API 'status'

This closes the loop between UI/schema aliasing and API execution. To keep requiredness logic consistent during execution, also remap the required_fields set to aliased names when comparing against param_fields:

# Outside the selected lines (~lines 1225-1227), after computing required_fields
renamed_required_fields = set()
for name in required_fields:
    if name == "user_id":
        renamed_required_fields.add(f"{self.app_name}_user_id")
    elif name == "status":
        renamed_required_fields.add(f"{self.app_name}_status")
    else:
        renamed_required_fields.add(name)
required_fields = renamed_required_fields

Optionally, replace the startswith/endswith pattern with exact equality for clarity:

-                if field.endswith("_user_id") and field.startswith(self.app_name):
+                if field == f"{self.app_name}_user_id":
                     final_field_name = "user_id"
-                elif field.endswith("_status") and field.startswith(self.app_name):
+                elif field == f"{self.app_name}_status":
                     final_field_name = "status"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ec7579d and b07fb11.

📒 Files selected for processing (1)
  • src/backend/base/langflow/base/composio/composio_base.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{src/backend/**/*.py,tests/**/*.py,Makefile}

📄 CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)

{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code

Files:

  • src/backend/base/langflow/base/composio/composio_base.py
🔇 Additional comments (1)
src/backend/base/langflow/base/composio/composio_base.py (1)

390-392: Ensure required‐fields list uses the aliased “status” field

In src/backend/base/langflow/base/composio/composio_base.py (around lines 390–392), you’ve aliased:

elif clean_field == "status":
    clean_field = f"{self.app_name}_status"

To keep a field marked required in the UI, you must also remap any occurrences of "status" in your required‐fields list to f"{self.app_name}_status" during schema preparation and execution. Otherwise the UI may drop “status” from its required checks.

• Review your schema‐processing block and confirm that every entry in the required list referencing "status" is replaced with the aliased name.
• If you don’t yet have that mapping, please add it so that required “status” remains required.

Let me know if you’d like me to draft a patch for remapping the required fields.

Comment on lines +539 to +550
# Update
field_schema_copy = field_schema.copy()
field_schema_copy["description"] = (
f"User ID for {self.app_name.title()}: " + field_schema["description"]
)
elif clean_field_name == "status":
clean_field_name = f"{self.app_name}_status"
# Update
field_schema_copy = field_schema.copy()
field_schema_copy["description"] = (
f"Status for {self.app_name.title()}: " + field_schema["description"]
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Potential KeyError when building descriptions for renamed fields

Both the "user_id" and "status" branches access field_schema["description"] unconditionally. If the source schema lacks a description (common), this will raise a KeyError and abort input generation.

Apply this diff to make the description handling safe:

-                    field_schema_copy = field_schema.copy()
-                    field_schema_copy["description"] = (
-                        f"User ID for {self.app_name.title()}: " + field_schema["description"]
-                    )
+                    field_schema_copy = field_schema.copy()
+                    base_desc = field_schema.get("description")
+                    field_schema_copy["description"] = (
+                        f"User ID for {self.app_name.title()}: {base_desc}"
+                        if base_desc
+                        else f"User ID for {self.app_name.title()}"
+                    )
@@
-                    field_schema_copy = field_schema.copy()
-                    field_schema_copy["description"] = (
-                        f"Status for {self.app_name.title()}: " + field_schema["description"]
-                    )
+                    field_schema_copy = field_schema.copy()
+                    base_desc = field_schema.get("description")
+                    field_schema_copy["description"] = (
+                        f"Status for {self.app_name.title()}: {base_desc}"
+                        if base_desc
+                        else f"Status for {self.app_name.title()}"
+                    )

Additionally, ensure the "required" list reflects the same renames to keep requiredness in sync with the aliased field names:

# Outside the selected lines, right after cleaned_required is computed (~lines 572-575)
if flat_schema.get("required"):
    cleaned_required = [field.replace("[0]", "") for field in flat_schema["required"]]
    # Reflect field renames (e.g., 'user_id' -> '<app>_user_id', 'status' -> '<app>_status')
    mapped_required = []
    for field in cleaned_required:
        if field == "user_id":
            mapped_required.append(f"{self.app_name}_user_id")
        elif field == "status":
            mapped_required.append(f"{self.app_name}_status")
        else:
            mapped_required.append(field)
    flat_schema["required"] = mapped_required

This avoids mislabeling required inputs as optional in the UI.

🤖 Prompt for AI Agents
In src/backend/base/langflow/base/composio/composio_base.py around lines 539 to
550, the code unconditionally accesses field_schema["description"] when renaming
"user_id" and "status", which can raise KeyError if description is missing;
change those accesses to use field_schema.get("description", "") (or check for
presence) before concatenating so description building is safe. Also, after
cleaned_required is computed (around lines ~572-575), map renamed fields into
the required list so requiredness stays in sync: iterate cleaned_required,
replace "user_id" with f"{self.app_name}_user_id" and "status" with
f"{self.app_name}_status", and assign the resulting list back to
flat_schema["required"].

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Aug 18, 2025
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Aug 21, 2025
@edwinjosechittilappilly edwinjosechittilappilly added this pull request to the merge queue Aug 22, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Aug 22, 2025
@sonarqubecloud
Copy link
Copy Markdown

Merged via the queue into langflow-ai:main with commit 8af1909 Aug 22, 2025
20 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the feat-composio-v3-2-hotfix1 branch August 22, 2025 10:11
lucaseduoli pushed a commit that referenced this pull request Aug 22, 2025
* fix: df handling

* fix: format

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
lucaseduoli pushed a commit that referenced this pull request Aug 25, 2025
* fix: df handling

* fix: format

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants