django-cookie-consent icon indicating copy to clipboard operation
django-cookie-consent copied to clipboard

Catch Unexpected Errors Part 2

Open 9mido opened this issue 4 years ago • 1 comments

Helps with #26 and prevents unexpected errors. Was not sure how to solve it otherwise. Part of the other pull request I made.

9mido avatar Jul 27 '20 21:07 9mido

Hi @9mido , perhaps focusing on the get_decline_cookie_groups_cookie_string is not the best approach, as it mainly call other functions.

The problem ultimately lies with the get_cookie_dict_from_request from utls.py

So, maybe something like this?

def get_cookie_dict_from_request(request):
    if hasattr(request, 'COOKIES'):
        cookie_str = request.COOKIES.get(settings.COOKIE_CONSENT_NAME)
    else:
        return
    return parse_cookie_str(cookie_str)

It's a bit more focused than your PR, but not something I would be comfortable with as I still don't understand why the templatetag is collecting a string request...

Also I don't know how to write a test for it. :/

MrCordeiro avatar Aug 01 '20 12:08 MrCordeiro

I agree with @bmihelac and @MrCordeiro that this approach isn't desired, as it hides the actual underlying problem. I will close this PR to clean up the repository, but leave the issue open so we can use that to further investigate what is happening.

sergei-maertens avatar Sep 04 '22 21:09 sergei-maertens