Skip to content

Validate activity funtion parameters and execute function body#6

Merged
rdulmina merged 5 commits intoballerina-platform:m1from
rdulmina:m1
Jan 30, 2026
Merged

Validate activity funtion parameters and execute function body#6
rdulmina merged 5 commits intoballerina-platform:m1from
rdulmina:m1

Conversation

@rdulmina
Copy link
Copy Markdown
Contributor

@rdulmina rdulmina commented Dec 10, 2025

Purpose

$title

The following validations are validated

  1. Activity function parameters should be a subtype of anydata.
  2. The execute function cannot access mutable global variables even inside a lock statement.
  3. Cannot use var binding pattern when calling an activity function

Fixes #8506

1. Activity function parameters should be a subtype of anydata.
2. The execute function cannot access mutable global variables even inside lock statement.
@rdulmina rdulmina requested a review from hasithaa as a code owner December 10, 2025 07:36
@rdulmina rdulmina requested review from Copilot and removed request for hasithaa December 10, 2025 07:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 85.18519% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.44%. Comparing base (cf2c6b2) to head (e97435a).
⚠️ Report is 12 commits behind head on m1.

Files with missing lines Patch % Lines
...compiler/analyzer/WorkflowServiceAnalysisTask.java 85.18% 3 Missing and 5 partials ⚠️
.../workflow/compiler/WorkflowCompilerPluginUtil.java 77.77% 0 Missing and 2 partials ⚠️
...ompiler/analyzer/WorkflowActivityAnalysisTask.java 85.71% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a 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 validation for workflow activity functions by implementing three new compiler diagnostics:

  1. WORKFLOW_107: Validates activity function parameters are subtypes of anydata
  2. WORKFLOW_108: Prevents execute function from accessing mutable global variables inside lock statements
  3. WORKFLOW_109: Disallows using var binding 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 var binding 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.

@hasithaa
Copy link
Copy Markdown
Contributor

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.

@hasithaa hasithaa closed this Jan 29, 2026
# 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
@rdulmina rdulmina reopened this Jan 30, 2026
@rdulmina rdulmina merged commit b4f71a9 into ballerina-platform:m1 Jan 30, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants