-
-
Notifications
You must be signed in to change notification settings - Fork 23.6k
Fix: Add regex comparison support to Condition Agentflow #5657
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
base: main
Are you sure you want to change the base?
Fix: Add regex comparison support to Condition Agentflow #5657
Conversation
Co-authored-by: shazee257 <50085698+shazee257@users.noreply.github.com>
Co-authored-by: shazee257 <50085698+shazee257@users.noreply.github.com>
Co-authored-by: shazee257 <50085698+shazee257@users.noreply.github.com>
Summary of ChangesHello @shazee257, 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 functional gap in the Condition Agentflow node by providing a robust backend implementation for regex comparisons. It ensures that users can safely and effectively utilize regular expressions within their agent flows, preventing previous runtime errors and enhancing the node's conditional logic capabilities. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly implements the missing regex operation for the Condition Agentflow node, including important safety checks to prevent runtime errors and expensive evaluations. The addition of unit tests is also great for ensuring the new functionality is robust. My feedback includes suggestions to improve code readability by using named constants, enhancing type safety in the tests, and expanding test coverage to include all safety checks.
packages/components/nodes/agentflow/Condition/Condition.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical bug where the Condition Agentflow node exposed a "Regex" operation in the UI but lacked the corresponding backend implementation, causing runtime errors when users attempted to use this feature.
Changes:
- Added regex comparator implementation with defensive safety limits (256 char pattern, 10,000 char input) and error handling for invalid patterns
- Added comprehensive unit tests covering successful regex matching, invalid pattern handling, and safety limit enforcement
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/components/nodes/agentflow/Condition/Condition.ts | Implements the missing regex comparison function with safety limits and error handling |
| packages/components/nodes/agentflow/Condition/Condition.test.ts | Adds new test suite with three test cases covering regex functionality, invalid patterns, and safety limits |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/components/nodes/agentflow/Condition/Condition.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Fixes #5650 - - Bug: "Regex" operation in Condition node is not implemented in backend
The Condition Agentflow node exposes a Regex operation in the UI but the backend did not implement it, causing runtime errors during evaluation. This update adds the missing backend behavior and ensures regex conditions evaluate safely.
Backend condition evaluation
regexcomparator with defensive limits and invalid-pattern handling to prevent runtime errors and mitigate expensive pattern evaluation.Tests
Example:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.sheetjs.com/usr/local/bin/node node /usr/local/bin/pnpm install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.