fix: surface readable error when server app exception cannot be deserialized#1029
fix: surface readable error when server app exception cannot be deserialized#1029David-Development wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 11 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
55ba94d to
49ec60f
Compare
49ec60f to
7a9cb45
Compare
…ialized The Files app serializes the original exception object over the AIDL pipe. If its class - or any class in its cause chain - only exists in the Files app (e.g. CertificateCombinedException from the owncloud library on SSL errors), ObjectInputStream#readObject throws a ClassNotFoundException in the client app, hiding the actual error behind a message like: java.lang.ClassNotFoundException: com.owncloud.android.lib.common.net... Catch the ClassNotFoundException during deserialization and replace it with a plain exception carrying the original type name and a hint to check the server connection. It flows through the existing parseNextcloudCustomException translation, so client apps get a proper SSOException (UnknownErrorException) instead of a raw ClassNotFoundException. Ref nextcloud/news-android#1645 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: David Luhmer <david-dev@live.de>
7a9cb45 to
a68134f
Compare
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Problem
When a request fails inside the Files app,
InputStreamBinderserializes the original exception object over the AIDL pipe. If the exception's class — or any class in its cause chain — only exists in the Files app (e.g.com.owncloud.android.lib.common.network.CertificateCombinedExceptionon SSL/certificate errors),ObjectInputStream#readObjectinAidlNetworkRequest#deserializeObjectV2throws aClassNotFoundExceptionin the client app.The real error is completely lost, and client apps end up showing something like:
See nextcloud/news-android#1645 for a report of exactly this (expired SSL certificate → cryptic
ClassNotFoundExceptionin the News app).Fix
Catch the
ClassNotFoundExceptionduring exception deserialization and replace it with a plain exception that carries the original type name plus a hint to check the server connection. It then flows through the existingSSOException#parseNextcloudCustomExceptiontranslation, so client apps receive a properSSOException(UnknownErrorException) and show their regular error dialog instead of a rawClassNotFoundException.This is the receiver-side safety net and works against all already-shipped Files app versions. Follow-up (separate PR in nextcloud/android): flatten exceptions to plain JRE types in
InputStreamBinder#serializeObjectToInputStreamV2before serializing, so the original error message survives the IPC as well, not just the type name.Tests
Added
AidlNetworkRequestTest:ClassNotFoundException) containing the original type name is returnednullexception + headers are still parsed correctly🤖 Generated with Claude Code