Skip to content

Conversation

@aibysid
Copy link

@aibysid aibysid commented Nov 13, 2025

Root Cause:
When deleting an Agentflow from the list view, updateFlowsApi.request() was called without pagination parameters. This caused the backend to return a plain array instead of the expected { data: [], total: 0 } format, leading to a TypeError when accessing .data.length.

Solution:

  • Created refreshAgentflows callback that includes current pagination state
  • Passed callback through FlowListTable to FlowListMenu
  • Updated handleDelete to use callback instead of direct API call
  • Maintains backward compatibility for components without callback

Note : This change is backward compatible will not break existing delete functionality cheers !

Fixes #5360

Root Cause: When deleting an Agentflow from the list view, updateFlowsApi.request() was called without pagination parameters. This caused the backend to return a plain array instead of the expected { data: [], total: 0 } format, leading to a TypeError when accessing .data.length. Solution: - Created refreshAgentflows callback that includes current pagination state - Passed callback through FlowListTable to FlowListMenu - Updated handleDelete to use callback instead of direct API call - Maintains backward compatibility for components without callback Fixes FlowiseAI#5360
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aibysid, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the Agentflow list view where deleting an item would lead to a UI error due to an unexpected API response format. The solution introduces a more robust and flexible refresh mechanism that correctly updates the list post-deletion, ensuring data consistency and a smoother user experience. It also improves error handling and maintains backward compatibility.

Highlights

  • Bug Fix: Agentflow Deletion Refresh: Resolved an issue where deleting an Agentflow caused a TypeError due to the backend returning an unpaginated array instead of the expected paginated object format. This ensures the list refreshes correctly after deletion.
  • New Refresh Callback Mechanism: Introduced an onRefresh callback prop, passed down from the Agentflows view through FlowListTable to FlowListMenu. This callback now handles refreshing the agentflow list while preserving the current pagination state.
  • Backward Compatibility: The handleDelete function in FlowListMenu now prioritizes the new onRefresh callback but falls back to the existing updateFlowsApi.request if onRefresh is not provided, ensuring no breakage for components without the new callback.
  • Robust Data Handling: Added a safety check in the Agentflows component to gracefully handle both array and object response formats from the getAllAgentflows API, preventing potential errors from inconsistent API responses.
  • Improved Error Logging: Enhanced error logging within the Agentflows component to provide more detailed information, including the problematic data and error stack, when processing agentflow data fails.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively addresses the issue of agentflow list refresh after deletion by introducing an onRefresh callback mechanism. This ensures that the list is properly updated, especially when dealing with paginated data, preventing TypeError issues. The changes are well-structured, passing the callback through components and updating the deletion logic to utilize it. The addition of more detailed error logging is also a good improvement for maintainability.

if (getAllAgentflows.data) {
try {
const agentflows = getAllAgentflows.data?.data
setTotal(getAllAgentflows.data?.total)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The setTotal call here might not correctly reflect the total number of items when getAllAgentflows.data is a plain array. According to the root cause, the backend might return a plain array instead of an object with data and total properties. If getAllAgentflows.data is a plain array, getAllAgentflows.data?.total will be undefined, leading to an incorrect total count for pagination. You should adjust this line to use the length of flowsArray if getAllAgentflows.data is an array, or getAllAgentflows.data?.total otherwise.

Suggested change
setTotal(getAllAgentflows.data?.total)
setTotal(Array.isArray(getAllAgentflows.data) ? getAllAgentflows.data.length : getAllAgentflows.data?.total)
Comment on lines +176 to +178
console.error('❌ Error processing agentflows data:', e)
console.error('Data that caused error:', getAllAgentflows.data)
console.error('Error stack:', e.stack)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Adding more detailed error logging, including the problematic data and the error stack, is a good practice. This significantly improves the debuggability of the application when unexpected data formats or errors occur during agentflow processing.

@HenryHengZJ
Copy link
Contributor

@aibysid thank you so much for all the PR! We'll get these reviewed ASAP!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants