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

Passing a null value to RecurrenceField will cause a TypeError #89

Closed
audiolion opened this issue Feb 28, 2017 · 8 comments
Closed

Passing a null value to RecurrenceField will cause a TypeError #89

audiolion opened this issue Feb 28, 2017 · 8 comments

Comments

@audiolion
Copy link

At this point in the code https://github.com/django-recurrence/django-recurrence/blob/master/recurrence/forms.py#L147 if the value you passed is None it will throw a TypeError, saying it expected a string or a buffer. Maybe a check should be done, if value is None then value = '' the empty string

@dominicrodger
Copy link
Contributor

How do you pass None to a form from the browser? Or are you using a form programmatically?

@audiolion
Copy link
Author

audiolion commented Mar 6, 2017

I found it during testing yes so the form data was being generated and passed programmatically, I basically added recurrence: '' to the POST.data to fix it, but I expected if I didn't pass the field name to the form post data it wouldn't crash. I wasn't doing recurrence: None in the post data, I didn't include it at all. (The RecurrenceField is called recurrence on my model) So the form cleaning that was done assigns a value of None to the field if it is not present.

@dominicrodger
Copy link
Contributor

Ah, OK - that makes sense, thanks @audiolion.

Pull requests to fix this welcome - especially if they contain tests!

@audiolion
Copy link
Author

Ok might be a few days but I will send in a patch

@dominicrodger
Copy link
Contributor

Sounds good - thanks! No pressure on getting it done, it doesn't sound like it would hit most users of django-recurrence. Don't worry if you can't get tests for it - I'll happily add them to a patch if needed.

@pytrumpeter
Copy link
Contributor

pytrumpeter commented Jun 22, 2018

Did this ever get patched? I'm running into this issue now. Thanks.

Edit: I monkey-patched it for now, so no rush. I returned None if a TypeError was thrown in the try/catch, seems to work okay for now, as my Recurrence field is not required.

@dominicrodger
Copy link
Contributor

@harveynr - no, I don't think this was ever patched.

pytrumpeter pushed a commit to pytrumpeter/django-recurrence that referenced this issue Jul 9, 2018
dominicrodger added a commit that referenced this issue Jul 11, 2018
added typeerror exception and test for #89
@dominicrodger
Copy link
Contributor

Fixed by #122.

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

No branches or pull requests

3 participants