Conversation
…/github.com/wordpress-mobile/WordPress-Android into feat/CMM-843-Create-the-Ask-the-HE-entry-UI
|
Claude finished @adalpari's task —— View job Code Review for PR #22323 ✅I've completed a comprehensive review of the attachment support implementation for HE tickets. Here are my findings: ✅ Positive Aspects
🔴 Critical Issues1. Resource Leak in Activity (HESupportActivity.kt:54)The Impact: Silent failures, poor UX Recommendation: photoPickerLauncher = registerForActivityResult(...) { result ->
if (result.resultCode == RESULT_OK && result.data != null) {
val uris = result.data?.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)
uris?.let { uriStrings ->
try {
val newUris = uriStrings.map { it.toUri() }
viewModel.addAttachments(newUris)
} catch (e: Exception) {
// Show error snackbar
}
}
}
}2. Exception Handling Too Broad (HESupportViewModel.kt:189-209)The ?: throw Exception("Failed to open input stream for attachment")Issues:
Recommendation: // Create specific exception classes
class AttachmentException(message: String, cause: Throwable? = null) : Exception(message, cause)
private suspend fun Uri.toTempFile(): File = withContext(ioDispatcher) {
try {
val inputStream = application.contentResolver.openInputStream(this@toTempFile)
?: throw AttachmentException("Cannot access file: permission denied or file not found")
// ... rest of implementation
} catch (e: SecurityException) {
throw AttachmentException("Permission denied to access file", e)
} catch (e: IOException) {
throw AttachmentException("Failed to copy file: ${e.message}", e)
}
}3. Missing Input Validation (HESupportRepository.kt:96-136)The repository accepts
Impact: Server errors, poor error messages, potential security issues Recommendation: Add validation in the repository layer before making API calls
|
We are just failing if the file is not supported. We can malke the error handling more fine grained in next iterations, but it's out fo scope for this one. |
It's coming |
Totally right, we need to set a max number of attachments. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #22323 +/- ##
==========================================
- Coverage 39.33% 39.21% -0.12%
==========================================
Files 2198 2201 +3
Lines 105412 105788 +376
Branches 14984 15009 +25
==========================================
+ Hits 41462 41485 +23
- Misses 60458 60811 +353
Partials 3492 3492 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* Showing attachments previews * Typo * Fixing pan issue * Passing attachments directly instead of searching for then when tapped for full screen * Compile fix * Fixing the send state message * Checking network availability * Saving message state when error * Tests * Reverting non-related commits done by mistake
|
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
Description
This PR is adding support to upload attachments inside HE tickes in the new support flow.
Showing the attachments as well, turned out to create a big PR, so the showing part has been moved to #22333
If you want to give a try to both PRs, you can test them consecutively.
Things to discuss/improve:
Testing instructions
NOTE: don0t forget to mark your ticket as solved in Zendesk
Screen_recording_20251103_113859.mp4