Skip to content

Update cookie validation regex in Get Cookies test#1973

Merged
emanlove merged 1 commit intorobotframework:masterfrom
yuriverweij:bugfix/get-cookies-atest
Apr 8, 2026
Merged

Update cookie validation regex in Get Cookies test#1973
emanlove merged 1 commit intorobotframework:masterfrom
yuriverweij:bugfix/get-cookies-atest

Conversation

@yuriverweij
Copy link
Copy Markdown
Member

Fix flaky Get Cookies test

The previous regex used | to handle any cookie ordering, but the ^ and $ anchors were not wrapping both alternatives, leaving each side only partially anchored and allowing substring matches. For example, the first alternative only required the string to start with test=seleniumlibrary; another=value, meaning a third cookie appended at the end would still pass.

All 3 cookies were always being returned, but the test was silently passing in the past because the browser was consistently returning cookies in an order that accidentally satisfied the faulty regex.

Replaced the regex with a stricter pattern that matches exactly 3 known cookies in any order, with no room for unexpected extras.

Fix flaky Get Cookies test

The previous regex used | to handle any cookie ordering, but the ^ and $ anchors were not wrapping both alternatives, leaving each side only partially anchored and allowing substring matches. For example, the first alternative only required the string to start with test=seleniumlibrary; another=value, meaning a third cookie appended at the end would still pass.

All 3 cookies were always being returned, but the test was silently passing in the past because the browser was consistently returning cookies in an order that accidentally satisfied the faulty regex.

Replaced the regex with a stricter pattern that matches exactly 3 known cookies in any order, with no room for unexpected extras.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a flaky acceptance test around Get Cookies by tightening the cookie-string validation so it no longer passes on partial/substring matches caused by incorrectly anchored alternation.

Changes:

  • Adds explicit assertions that all three expected cookies are present in the returned cookie string.
  • Replaces the prior alternation-based regex with a fully anchored regex that matches exactly three name=value cookie pairs (in any order) separated by ; .

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@emanlove emanlove merged commit eea629c into robotframework:master Apr 8, 2026
4 of 7 checks passed
@emanlove emanlove added bug priority: high acknowledge To be acknowledged in release notes labels Apr 8, 2026
@emanlove emanlove added this to the Jan 2026 milestone Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

acknowledge To be acknowledged in release notes bug priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants