Skip to content

[py] Validate WebSocket response interval correctly - #17984

Merged
cgoldberg merged 3 commits into
SeleniumHQ:trunkfrom
cuishuang:fix-python-websocket-interval
Oct 1, 2026
Merged

cgoldberg merged 3 commits into
SeleniumHQ:trunkfrom
cuishuang:fix-python-websocket-interval

Conversation

@cuishuang

@cuishuang cuishuang commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Related Issues

💥 What does this PR do?

Fixes Python WebSocket response interval validation.

The existing validation checks timeout < 0 twice:

if not isinstance(interval, (int, float)) or timeout < 0:

As a result, non-positive intervals can pass validation. An interval of -0.1 later reaches sleep(-0.1), while an interval of 0 prevents _wait_until() from reducing its remaining timeout and can cause an infinite loop.

This changes the validation to reject all non-positive interval values:

if not isinstance(interval, (int, float)) or interval <= 0:

A unit regression test covers negative, zero, and positive interval values without requiring a browser or WebSocket server.

🔧 Implementation Notes

The interval must be strictly positive because _wait_until() subtracts it from the remaining timeout and passes it to sleep().

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s):
    • What was generated:
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • Bug fix (backwards compatible)

Signed-off-by: cuishuang <imcusg@gmail.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@CLAassistant

CLAassistant commented Sep 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@selenium-ci selenium-ci added the C-py Python Bindings label Sep 5, 2026
@cuishuang

Copy link
Copy Markdown
Contributor Author

@nvborisenko @titusfortner
Could you please take a look when you have a chance? Thanks!

@qodo-code-review

qodo-code-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@cgoldberg
cgoldberg self-requested a review October 1, 2026 01:59

@cgoldberg cgoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
good catch.

@cgoldberg
cgoldberg merged commit 4bac0b9 into SeleniumHQ:trunk Oct 1, 2026
30 checks passed
This was referenced Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants