Repository navigation
[py] Prevent TypeError and KeyError in ErrorHandler when value is None or missing - #18239
Merged
cgoldberg merged 1 commit intoOct 25, 2026
Conversation
Contributor
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
…e or missing
When WebDriver server responds with an error where 'value' is None or
omitted entirely from the response dictionary, ErrorHandler crashed with
KeyError ('value') or TypeError (argument of type 'NoneType' is not iterable)
instead of raising the appropriate WebDriverException subclass.
Safely extract value with response.get('value') and guard dictionary
operations with isinstance(value, dict).
saiyam-jain-dev
force-pushed
the
fix-errorhandler-none-or-missing-value
branch
from
October 25, 2026 06:48
cba6edc to
44fe882
Compare
cgoldberg
self-requested a review
October 25, 2026 14:38
cgoldberg
approved these changes
Oct 25, 2026
cgoldberg
left a comment
Member
There was a problem hiding this comment.
LGTM 👍
I'll merge this after CI runs.
Thanks for your first contribution @saiyam-jain-dev!
Contributor
Author
|
Thank you @cgoldberg! Glad to contribute to Selenium. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a WebDriver server returns an error response where
"value" isNoneor omitted from the response dictionary:"value"was missing,response["value"]raisedKeyError: 'value'."value"wasNone:if message == ""and"message" in valueraisedTypeError: argument of type 'NoneType' is not iterable.In both cases,
ErrorHandler.check_response()crashed with an unexpected internal exception instead of translating the status code into the appropriateWebDriverExceptionsubclass (e.g.NoSuchElementException,TimeoutException,WebDriverException).This PR:
response.get("value")instead ofresponse["value"]."message" in value,"screen" in value,value.get("stackTrace"), alert data, etc.) withisinstance(value, dict).value=None, missingvalue, and numeric status codes without a payload.Motivation and Context
Prevents unhandled
KeyErrorandTypeErrorwhen WebDriver or intermediary proxy/gateway returns an error response without a payload or with a null value.Types of changes
Checklist