Repository navigation
Conversation
`_cookie_filter` always set `flags=flags or None`, so a compiled pattern
without i/m/s went over the wire as `"flags": null`, which the protocol's
`CookieRegex` schema rejects — `clear_cookies(name=re.compile("session"))`
failed while the plain string form worked. Leave the field unset when there
is no flag to send.
Python regex flags that the wire format cannot carry (ASCII, LOCALE,
VERBOSE, DEBUG) were dropped silently, so a caller could get a different
pattern than the one it compiled. Reject them with a clear error instead.
Closes browserbase#3270
🦋 Changeset detectedLatest commit: 51ef2bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
Marks the clear_cookies regex filter fix as a patch for @browserbasehq/stagehand-python so changesets picks it up.
This branch has not been deployed
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.
Fixes #3270.
_cookie_filteralways passedflags=flags or None, so a compiled pattern withouti/m/swas serialized withexclude_unset=Trueas"flags": null.CookieRegexin the protocol schema declaresflagsas.optional(), which accepts a missing key but notnull, so the RPC call was rejected and the cookie was never cleared — the plain string form worked, which is why this only hit compiled patterns.flagsunset when there is nothing to send.re.ASCII,re.LOCALE,re.VERBOSE,re.DEBUG) with a clearValueErrorinstead of dropping them silently and running a different pattern than the caller compiled.Tests in
packages/sdk-python/tests/test_browser_context.py:test_browser_context_omits_unused_cookie_regex_flagsasserts the serialized filter has noflagskey.test_browser_context_rejects_unrepresentable_cookie_regex_flagscoversre.VERBOSE.Summary by cubic
Fixes
clear_cookiesso compiled regex patterns withouti/m/sflags no longer fail: the filter was serialized with"flags": null, which the protocol schema rejects, while plain string filters worked. The serialized filter now simply omitsflagswhen there is no flag to send.Also rejects Python-only regex flags (
re.ASCII,re.LOCALE,re.VERBOSE,re.DEBUG) with a clearValueErrorinstead of silently dropping them and running a different pattern than the caller compiled.Adds a changeset marking this fix as a patch for
@browserbasehq/stagehand-python.Written for commit 51ef2bf. Summary will update on new commits.