Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): Patch firefox_profile.py from Selenium package #29887

Merged
merged 5 commits into from
Nov 15, 2021

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Nov 9, 2021

Running pytest in getsentry triggers a bug in firefox_profile.py from the Selenium driver. Upgrading to version 4 is quite involved. This is a stop-gap to prevent distracting engineers when it happens.

This is the output when we patch it:

--> Installing Sentry (for development)
We are patching .venv/lib/python3.8/site-packages/selenium/webdriver/firefox/firefox_profile.py. You will see this message only once.
--- .venv/lib/python3.8/site-packages/selenium/webdriver/firefox/firefox_profile.py	2021-11-09 16:40:20.000000000 -0500
+++ .venv/lib/python3.8/site-packages/selenium/webdriver/firefox/firefox_profile.py.bak	2021-11-09 16:40:03.000000000 -0500
@@ -207,3 +207,3 @@
     def _set_manual_proxy_preference(self, key, setting):
-        if setting is None or setting == '':
+        if setting is None or setting is '':
             return

@armenzg armenzg self-assigned this Nov 9, 2021
@armenzg armenzg added the Component: Developer Environment This covers issues related to setting up a developer's environment label Nov 9, 2021
@armenzg armenzg requested review from joshuarli and scefali November 9, 2021 21:46
@armenzg armenzg marked this pull request as ready for review November 10, 2021 19:59
@armenzg armenzg requested review from a team as code owners November 10, 2021 19:59
@armenzg
Copy link
Member Author

armenzg commented Nov 10, 2021

We can ignore the Ubuntu dev env check.

scripts/lib.sh Outdated
# Remove this block when upgrading the selenium package
if grep -q "or setting is" "${fx_profile}"; then
echo "We are patching ${fx_profile}. You will see this message only once."
sed -i .bak 's/or setting is/or setting ==/' ${fx_profile}
Copy link
Member

Choose a reason for hiding this comment

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

Could you instead generate a patch and put it in scripts/patches, then idempotently patch? Patching shouldn't be done like this.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, lemme take this over and show you what I mean.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. WFM

@armenzg armenzg removed the request for review from scefali November 11, 2021 16:20
scripts/lib.sh Outdated
# Remove this block when upgrading the selenium package
if grep -q "or setting is" "${fx_profile}"; then
echo "We are patching ${fx_profile}. You will see this message only once."
sed -i .bak 's/or setting is/or setting ==/' ${fx_profile}
Copy link
Member

Choose a reason for hiding this comment

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

Actually, lemme take this over and show you what I mean.

# Remove this block when upgrading the selenium package
if grep -q "or setting is" "${fx_profile}"; then
echo "We are patching ${fx_profile}. You will see this message only once."
patch -p0 <scripts/patches/firefox_profile.diff
Copy link
Member

Choose a reason for hiding this comment

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

Instead of guarding with the grep, you can idempotently (--forward) apply the patch like this: patch -p0 --forward -r=/dev/null < scripts/patches/firefox_profile.diff. The -r=/dev/null is just to prevent it writing a reject file in the case of failure, but it still exits nonzero.

Copy link
Member

Choose a reason for hiding this comment

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

Oh hmm, it still exits 1. Never mind.

Copy link
Member

Choose a reason for hiding this comment

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

@@ -89,5 +89,5 @@ phabricator==0.7.0

# test dependencies, but unable to move to requirements-test until
# sentry.utils.pytest and sentry.testutils are moved to tests/
selenium==3.141.0
selenium==3.141.0 # XXX: Remove hack from lib.sh when upgrading
Copy link
Member

Choose a reason for hiding this comment

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

@armenzg can you comment the PR link/number here for future reference?

Copy link
Member

@dashed dashed left a comment

Choose a reason for hiding this comment

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

Looking forward for this patch!

@scefali
Copy link
Contributor

scefali commented Nov 29, 2021

@armenzg So, this fix doesn't seem to fix the issue when I run in getsentry:

  File "/Users/scefali/Work/getsentry/.venv/lib/python3.8/site-packages/selenium/webdriver/firefox/firefox_profile.py", line 208
    if setting is None or setting is '':

@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: Developer Environment This covers issues related to setting up a developer's environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants