Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

[java] Improve screenshot error message#17120

Open
seethinajayadileep wants to merge 2 commits intoSeleniumHQ:trunkfrom
seethinajayadileep:improve-screenshot-error-message
Open

[java] Improve screenshot error message#17120
seethinajayadileep wants to merge 2 commits intoSeleniumHQ:trunkfrom
seethinajayadileep:improve-screenshot-error-message

Conversation

@seethinajayadileep
Copy link

💥 What does this PR do?

Improves the diagnostic information included in theWebDriverException
thrown when creating or writing the temporary screenshot file fails in
OutputType.FILE.

The originalIOException is preserved as the cause.

🔧 Implementation Notes

  • Keeps behavior unchanged except for the exception message in failure cases.
  • Includes the temp file path (when available) to make debugging file-system
    failures easier.

💡 Additional Considerations

  • No public API changes.
  • No behavioral changes in success cases.
  • This change only affects the error message when anIOException occurs.

🔄 Types of changes

  • Bug fix (backwards compatible)
  • Cleanup (formatting, renaming)

Adds contextual information to WebDriverException thrown during temporary screenshot file creation or write failure.Preserves original IOException as cause.
@CLAassistant
Copy link

CLAassistant commentedFeb 20, 2026
edited
Loading

CLA assistant check
All committers have signed the CLA.

@qodo-code-review
Copy link
Contributor

PR Type

Bug fix, Enhancement


Description

  • Improves diagnostic information in screenshot file creation failures

  • Includes temporary file path in exception message for better debugging

  • Preserves original IOException as cause for error tracing

  • Refactors code structure for clearer error handling flow


File Walkthrough

Relevant files
Bug fix
OutputType.java
Enhanced screenshot error handling with file path details

java/src/org/openqa/selenium/OutputType.java

  • Enhancedsave() method to capture and include temporary file path in
    exception messages
  • Modified error handling to provide contextual information about file
    creation/write failures
  • Restructured try-catch block to tracktmpFilePath variable for error
    reporting
  • Improved exception message to distinguish between file creation and
    write failures
+19/-10 

@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Path information exposure

Description: The newWebDriverException message includes the absolute temporary file path
(tmpFilePath.toAbsolutePath()), which can leak sensitive local filesystem information
(e.g., usernames, home/work directories) into logs or upstream error reporting systems.
OutputType.java [91-97]

Referred Code
StringpathInfo = (tmpFilePath !=null)     ?tmpFilePath.toAbsolutePath().toString()     :"temporary file could not be created";thrownewWebDriverException("Failed to create or write screenshot to temporary file: " +pathInfo,e);
Ticket Compliance
🎫No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow theguide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliancegeneric rules or creating your owncustom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliancegeneric rules or creating your owncustom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliancegeneric rules or creating your owncustom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliancegeneric rules or creating your owncustom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliancegeneric rules or creating your owncustom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status:
Path disclosure risk: The newWebDriverException message includes the screenshot temp file absolute path which
may expose internal filesystem details if this exception is surfaced to end-users.

Referred Code
StringpathInfo = (tmpFilePath !=null)     ?tmpFilePath.toAbsolutePath().toString()     :"temporary file could not be created";thrownewWebDriverException("Failed to create or write screenshot to temporary file: " +pathInfo,e);

Learn more about managing compliancegeneric rules or creating your owncustom rules

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

@qodo-code-review
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                   Impact
Possible issue
schedule deleteOnExit earlier

Schedule the temporary file for deletion immediately after its creation to
ensure cleanup even if the subsequent write operation fails.

java/src/org/openqa/selenium/OutputType.java [88-89]

 tmpFilePath = Files.createTempFile("screenshot", ".png");+File tmpFile = tmpFilePath.toFile();+tmpFile.deleteOnExit(); Files.write(tmpFilePath, data);
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a resource leak where a temporary file is not cleaned up if writing to it fails, and proposes a valid fix by moving the deletion scheduling.

Medium
  • More

@cgoldbergcgoldberg changed the titleImprove screenshot error message[java] Improve screenshot error messageFeb 20, 2026
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@seethinajayadileep@CLAassistant@selenium-ci

[8]ページ先頭

©2009-2026 Movatter.jp