Fix silent error handling in FTP listener#1549
Conversation
📝 WalkthroughWalkthroughValidates fileNamePattern regexes at initialization and shifts many runtime logger Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
Validate @ftp:FunctionConfig.fileNamePattern regex patterns during initialization rather than catching errors at runtime.
Native side log.error() calls are not visible to users, causing silent failures. Changed to create BError and call printStackTrace() for Ballerina-formatted error output.
Replace log.error with BError.printStackTrace for visible error output.
e36b6fc to
c17d593
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@native/src/main/java/io/ballerina/stdlib/ftp/server/FtpListener.java`:
- Around line 171-175: The fallback branch currently calls
onFileChangeMethodType.get() which can throw if absent; update FtpListener to
first check Optional.isPresent() for the result of
getOnFileChangeMethod(service) and only call
processMetadataOnlyCallbacks(service, event, onFileChangeMethodType.get(),
caller) when present; if not present, handle defensively (e.g., log a clear
warning/error with context using the existing logger and return or skip
processing) so there is no uncaught NoSuchElementException.
|
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (76.61%) 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 #1549 +/- ##
============================================
+ Coverage 76.53% 76.61% +0.07%
Complexity 1043 1043
============================================
Files 76 76
Lines 4833 4823 -10
Branches 838 837 -1
============================================
- Hits 3699 3695 -4
+ Misses 760 755 -5
+ Partials 374 373 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|



Summary
Problem
Native side
log.error()calls are not visible to users, causing the FTP listener to silently fail in various error scenarios.Solution
Changed to create
BErrorand callprintStackTrace()which outputs Ballerina-formatted errors that are visible to users.Fixes: ballerina-platform/ballerina-library#8655
🤖 Generated with Claude Code
Summary
This pull request improves error visibility and early configuration validation in the FTP listener so configuration and runtime problems are reported clearly to users instead of being silently lost.
Changes
Outcome
Improves stability and debuggability of the FTP listener by surfacing configuration and runtime errors in a consistent, user-visible format and by catching invalid filename patterns earlier during initialization.