-
Notifications
You must be signed in to change notification settings - Fork 68
Add schema validation for BranchNode gRPC objects #248
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
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Chris Li <chris.li.2046@gmail.com>
Formatted Go code using gofmt.
Co-Authored-By: Chris Li <chris.li.2046@gmail.com>
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 adds schema validation for BranchNode gRPC objects to prevent malformed data from being accepted during deserialization. Key changes include enhancing validation logic in the branch processor and adding comprehensive unit tests for various malformed condition cases.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
core/taskengine/vm_runner_branch.go | Added validation for nil conditions, empty/invalid IDs and types, with logging for misplaced "else" conditions. |
core/taskengine/vm_runner_branch_test.go | Introduced unit tests to verify the schema validation behavior for branch node conditions. |
return fmt.Errorf("condition at index %d has empty type", i) | ||
} | ||
|
||
if condition.Type != "if" && condition.Type != "else" { |
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.
The PR description mentions schema validation for the condition expression, but no validation is implemented for the 'expression' field. Please either add validation for 'expression' or update the PR description to accurately reflect the implemented behavior.
Copilot uses AI. Check for mistakes.
Thank you for the feedback! You're right that the PR description mentioned validation for expressions but our implementation doesn't reject empty expressions. This is intentional, as we found that existing tests (specifically TestBranchNodeEmptyConditionIsAPass) expect empty expressions to be allowed and treated as falsy. I've updated the PR description to clarify this design decision. |
Add schema validation for BranchNode gRPC objects
Description
This PR implements schema validation for BranchNode gRPC objects to prevent malformed data from being accepted, which can cause deserialization failures when retrieving workflows.
Changes
Testing
Added unit tests to verify validation works correctly for various malformed data cases.
Related Issues
Fixes #140
Link to Devin run
https://app.devin.ai/sessions/aafc6baafac442cb88f6df9be82b1d29
Requested by
Chris Li (chris@avaprotocol.org)