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

A blank string used for placeholder replacement can cause memory issue #169

Closed
pjbollinger opened this issue Jul 12, 2019 · 1 comment · Fixed by #170
Closed

A blank string used for placeholder replacement can cause memory issue #169

pjbollinger opened this issue Jul 12, 2019 · 1 comment · Fixed by #170

Comments

@pjbollinger
Copy link

Version: betamax-0.8.0

If you define a placeholder as described in the following, it can lead to memory issues, depending on how many blank strings you're trying to replace.

username = ''
config.define_cassette_placeholder('<USERNAME>', username)

For example, if I have the original string 'WOW' and perform the .replace() function, it will result in the following.

>>> 'WOW'.replace('','<USERNAME>')
'<USERNAME>W<USERNAME>O<USERNAME>W<USERNAME>'

If you have multiple placeholders with a blank string, this compounds and can cause a memory issue. I experienced this issue in src.betamax.cassette.interaction.py::Interaction::replace_in_uri, but would think this is applicable to all functions that use str.replace() and it looks like it exists on the most current version of betamax too.

I can submit a PR to check for blank strings prior to calling str.replace(), but figure I'd bring it up in an issue first.

@hroncok
Copy link
Member

hroncok commented Jul 12, 2019

Since emoji responses don't send notifications, I'm letting you know I like the idea to check for blank strings and refusing to continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants