Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an onError handler for FTP services to handle content binding failures. When file content cannot be converted to the expected type (JSON, XML, CSV, or record types), a new ContentBindingError is raised. Services can define an optional onError remote function to handle these errors, enabling custom error handling such as moving failed files or logging.
Changes:
- Added
ContentBindingErrortype with detail record containing file path and raw content bytes - Introduced
onErrorremote function support with validation (acceptsftp:Errororerroras first parameter, optionalCalleras second) - Updated content converters to return
ContentBindingErrorinstead of generic errors, with file path context - Added comprehensive compiler plugin validation and tests for the new error handler
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ballerina/error.bal | Defines ContentBindingError type and detail record |
| ballerina/tests/listener_on_error_test.bal | Tests onError handler with various scenarios including minimal/full parameters and caller operations |
| ballerina/tests/client_endpoint_test.bal | Tests ContentBindingError is returned from client operations on parsing failures |
| native/src/main/java/io/ballerina/stdlib/ftp/util/FtpUtil.java | Adds getOnErrorMethod() and createContentBindingError() helper methods |
| native/src/main/java/io/ballerina/stdlib/ftp/util/FtpContentConverter.java | Updates converters to return ContentBindingError with file path and content |
| native/src/main/java/io/ballerina/stdlib/ftp/util/FtpConstants.java | Adds ON_ERROR_REMOTE_FUNCTION and CONTENT_BINDING_ERROR constants |
| native/src/main/java/io/ballerina/stdlib/ftp/server/FtpContentCallbackHandler.java | Implements onError routing when content binding fails |
| native/src/main/java/io/ballerina/stdlib/ftp/server/FormatMethodsHolder.java | Tracks onError method availability |
| native/src/main/java/io/ballerina/stdlib/ftp/client/FtpClient.java | Passes file path to content converters for error context |
| compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/PluginConstants.java | Adds error codes and constants for onError validation |
| compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpServiceValidator.java | Integrates onError validation into service validation |
| compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpOnErrorValidator.java | Validates onError function signature and parameters |
| compiler-plugin-tests/* | Adds test cases for valid and invalid onError handlers |
| spotbugs-exclude.xml | Excludes EI_EXPOSE_REP2 for FtpOnErrorValidator |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...er-plugin-tests/src/test/resources/ballerina_sources/valid_on_error_service_3/Ballerina.toml
Show resolved
Hide resolved
compiler-plugin-tests/src/test/resources/ballerina_sources/valid_on_error_service_3/service.bal
Show resolved
Hide resolved
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/PluginConstants.java
Outdated
Show resolved
Hide resolved
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/PluginConstants.java
Outdated
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@niveathika I've opened a new pull request, #1538, to work on those changes. Once the pull request is ready, I'll request review from you. |
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (78.47%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1537 +/- ##
============================================
+ Coverage 77.89% 78.47% +0.58%
- Complexity 709 938 +229
============================================
Files 55 71 +16
Lines 3537 4237 +700
Branches 591 735 +144
============================================
+ Hits 2755 3325 +570
- Misses 547 604 +57
- Partials 235 308 +73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpOnErrorValidator.java
Outdated
Show resolved
Hide resolved
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpOnErrorValidator.java
Show resolved
Hide resolved
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpServiceValidator.java
Show resolved
Hide resolved
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/PluginConstants.java
Show resolved
Hide resolved
|



Purpose
Fixes ballerina-platform/ballerina-library#8605
Examples
Checklist