Validate activity funtion parameters and execute function body#6
Validate activity funtion parameters and execute function body#6rdulmina merged 5 commits intoballerina-platform:m1from
Conversation
1. Activity function parameters should be a subtype of anydata. 2. The execute function cannot access mutable global variables even inside lock statement.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## m1 #6 +/- ##
============================================
+ Coverage 79.32% 81.44% +2.12%
- Complexity 55 66 +11
============================================
Files 17 18 +1
Lines 237 318 +81
Branches 37 52 +15
============================================
+ Hits 188 259 +71
- Misses 26 29 +3
- Partials 23 30 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds validation for workflow activity functions by implementing three new compiler diagnostics:
- WORKFLOW_107: Validates activity function parameters are subtypes of
anydata - WORKFLOW_108: Prevents execute function from accessing mutable global variables inside lock statements
- WORKFLOW_109: Disallows using
varbinding pattern when calling activity functions
Key Changes
- Added parameter type validation for functions annotated with
@workflow:Activity - Implemented execute function body validation using a NodeVisitor pattern to detect mutable isolated variable access within lock statements
- Added validation to prevent
varbinding patterns in activity function calls to ensure explicit typing
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WorkflowDiagnostic.java | Added three new diagnostic error codes (WORKFLOW_107-109) for activity function validation |
| WorkflowServiceAnalysisTask.java | Added ExecuteFunctionBodyValidator to validate execute function for mutable variable access and var binding usage |
| WorkflowAnalyzer.java | Registered WorkflowActivityAnalysisTask for FUNCTION_DEFINITION syntax nodes |
| WorkflowActivityAnalysisTask.java | New task to validate activity function parameters are anydata subtypes |
| WorkflowCompilerPluginUtil.java | Added isActivityFunction helper to check for @workflow:Activity annotation |
| Constants.java | Added ACTIVITY constant for annotation name |
| Test files | Added comprehensive test cases for all three new validations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Closing this PR since we are taking a new approach to implement workflows. If the conflicts are resolved, we can merge this to the m1 branch. |
# Conflicts: # compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/Constants.java # compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowCompilerPluginUtil.java
Purpose
$title
The following validations are validated
Fixes #8506