Skip to content

fix(warnings): fix warnings in unescape_string - #26900

Merged
joshuarli merged 11 commits into
masterfrom
suppress-warning-in-unescape-string
Jun 29, 2021
Merged

joshuarli merged 11 commits into
masterfrom
suppress-warning-in-unescape-string

Conversation

@joshuarli

Copy link
Copy Markdown
Member

Currently on each process warmup, 3 DeprecationWarnings are issued while loading grouping enhancers:

/usr/src/getsentry/src/sentry/src/sentry/utils/strings.py:45: DeprecationWarning: invalid escape sequence '\{'
  "unicode-escape", "unicode-escape-recovery"
/usr/src/getsentry/src/sentry/src/sentry/utils/strings.py:45: DeprecationWarning: invalid escape sequence '\*'
  "unicode-escape", "unicode-escape-recovery"
/usr/src/getsentry/src/sentry/src/sentry/utils/strings.py:45: DeprecationWarning: invalid escape sequence '\P'
  "unicode-escape", "unicode-escape-recovery" 

image

For now the easiest way is just to preserve behavior. It won't affect Python 3.8 as it's still the same warning.

So, suppress the warning and add some tests to explain and assert for current behavior.

This is the last recurring warning to fix or suppress before #26796.

Comment thread src/sentry/utils/strings.py Outdated
return value.encode("ascii", "backslashreplace").decode(
"unicode-escape", "unicode-escape-recovery"
)
with warnings.catch_warnings():

@untitaker untitaker Jun 28, 2021 •

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.

I don't think we can do this, catch_warnings looks like it applies to the entire process rather than the current thread

not sure if there's any easier way

do you have a link to the sentry issue? it may be simpler to fix the values in the db (seems like this is loaded from projectoptions)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://sentry.io/organizations/sentry/issues/2476704750/?project=1

Ah yeah, that's unfortunate :\

I'll opt for fixing the files instead of catch_warnings.

@joshuarli joshuarli changed the title chore: suppress warnings in unescape_string fix(warnings): fix warnings in unescape_string Jun 28, 2021

@untitaker untitaker 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.

we will have invalid escape sequences in the DB as well, as the text files you just edited can also be user input. It would probably make sense to write a small migration that deals with those, on st/onprem as well

@joshuarli
joshuarli merged commit d092577 into master Jun 29, 2021
@joshuarli
joshuarli deleted the suppress-warning-in-unescape-string branch June 29, 2021 16:54
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2021

This branch was successfully deployed

2 active deployments
Preview – storybook — 49a1e96e Deployed Jun 29, 2021 by vercel[bot]
Preview – sentry — 49a1e96e Deployed Jun 29, 2021 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants