Skip to content

Conversation

diemol
Copy link
Member

@diemol diemol commented Oct 13, 2025

User description

🔗 Related Issues

Fixes #16388

💥 What does this PR do?

Every now and then, someone complains because the real reason a remote session creation fails is hidden in the stack trace. This identifies the cause, if it exists, and displays it at the top level.


PR Type

Bug fix


Description

  • Improved error messaging for remote session creation failures

  • Extracts and displays the underlying cause message at the top level

  • Prevents real error reasons from being hidden in stack traces


Diagram Walkthrough

flowchart LR
  A["Session Creation Error"] --> B["Check for Cause"]
  B --> C["Extract Cause Message"]
  C --> D["Display at Top Level"]
Loading

File Walkthrough

Relevant files
Bug fix
RemoteWebDriver.java
Enhanced remote session error message extraction                 

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

  • Enhanced error handling in execute() method for NEW_SESSION command
  • Extracts cause message from exception chain when available
  • Appends cause message to SessionNotCreatedException for better
    visibility
+5/-1     

@selenium-ci selenium-ci added the C-java Java Bindings label Oct 13, 2025
Copy link
Contributor

qodo-merge-pro bot commented Oct 13, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link
Contributor

qodo-merge-pro bot commented Oct 13, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent "null" in exception message

Replace e.getCause().getMessage() with e.getCause().toString() to prevent a
literal "null" from appearing in the exception message if the cause's message is
null.

java/src/org/openqa/selenium/remote/RemoteWebDriver.java [575-583]

 // When this exception comes from a remote end, the real cause is usually hidden in the
 // cause. Let's try to rescue it and display it at the top level.
-String cause = e.getCause() != null ? e.getCause().getMessage() : "";
+String cause = e.getCause() != null ? e.getCause().toString() : "";
 toThrow =
     new SessionNotCreatedException(
         "Possible causes are invalid address of the remote server or browser start-up"
             + " failure. "
             + cause,
         e);
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that e.getCause().getMessage() can return null, which would result in a confusing error message. Using e.getCause().toString() is a more robust approach that improves the quality of the error handling introduced in this PR.

Low
  • Update

@diemol diemol merged commit d66494e into trunk Oct 13, 2025
46 of 47 checks passed
@diemol diemol deleted the rescue_remote_cause branch October 13, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: [java] No proper error message misleading the user to analyze

4 participants