-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] Be more tolerant to remote responses #16797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[java] Be more tolerant to remote responses #16797
Conversation
* Some responses don't contain the required field "error" - just treat them as "unknown error" * If response doesn't contain the required field "message", just write the whole response as the message.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
User description
🔗 Related Issues
Improves #16389
🔄 Types of changes
PR Type
Bug fix, Tests
Description
Handle remote responses missing required "error" field gracefully
Use response toString as fallback when "message" field missing
Create InvalidResponseException for malformed response detection
Add comprehensive test coverage for edge cases
Diagram Walkthrough
flowchart LR A["Remote Response"] --> B{"Has 'value' field?"} B -->|No| C["Throw InvalidResponseException"] B -->|Yes| D{"Has 'error' field?"} D -->|No| E["Use empty string as error"] D -->|Yes| F{"Error is String?"} F -->|No| C F -->|Yes| G{"Match known error?"} G -->|Yes| H["Create specific exception"] G -->|No| I["Create WebDriverException with error code"] E --> J{"Has 'message' field?"} J -->|No| K["Use response toString"] J -->|Yes| L{"Message is String?"} L -->|No| C L -->|Yes| M["Use message value"]File Walkthrough
ErrorCodec.java
Improve remote response error handling robustnessjava/src/org/openqa/selenium/remote/ErrorCodec.java
requireNonNullElse,requireNonNullElseGet, andOptionalDEFAULT_ERRORconstantdecode()method to handle missing "error" and "message"fields
IllegalArgumentExceptiontoInvalidResponseExceptionmessage
InvalidResponseException.java
New exception for malformed remote responsesjava/src/org/openqa/selenium/remote/InvalidResponseException.java
IllegalArgumentExceptionErrorCodecTest.java
Add tests for edge case response handlingjava/test/org/openqa/selenium/remote/ErrorCodecTest.java