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

UnicodeDecodeError when receiving flag_info info error #26

Closed
alvarovelezgalvez opened this issue May 12, 2014 · 9 comments
Closed

UnicodeDecodeError when receiving flag_info info error #26

alvarovelezgalvez opened this issue May 12, 2014 · 9 comments

Comments

@alvarovelezgalvez
Copy link

Hi all,

First of all thanks to spookylukey (and also dcramer) for this super library. I have recently discovered that sometimes Paypal is returning some unreadable characters in the 'flag_info' field and an UnicodeDecodeException exception is raised in the following line:
self.flag_info += info
of file: django_paypal-0.1.3-py2.7.egg/paypal/standard/models.py

I guess that a try/catch surrounding the line and managing the unicode variable properly should be enough to fix it.

Best regards from Barcelona,
Álvaro Vélez.

@spookylukey
Copy link
Owner

A try/catch is a last resort, and would mask the underlying problem. If you can provide the exact circumstance (ie. extract of HTTP request) which cause it, we can put in a proper solution. Thanks!

@alvarovelezgalvez
Copy link
Author

I couldn't be able to store the HTTP request in the logs, but I have enabled it from now, to store in case I receive again the error.

I'll keep you up to date.

Thanks!

@spookylukey
Copy link
Owner

Closing as not enough info was provided, and this is old now.

@rafaelks
Copy link

Hi,

I'm having this error in my application using version 0.2. This is the request params that's causing this:

{
  "protection_eligibility": "Ineligible",
  "last_name": "Bar",
  "txn_id": "25F78140PL237475G",
  "receiver_email": "foo@bar.com",
  "payment_status": "Completed",
  "tax": "0.00",
  "residence_country": "BR",
  "invoice": "0c85c58f-df5b-baz-bar-foo",
  "payer_status": "unverified",
  "txn_type": "web_accept",
  "handling_amount": "0.00",
  "payment_date": "17:00:38 Apr 19, 2015 PDT",
  "first_name": "Foo",
  "item_name": "Foobar",
  "charset": "windows-1252",
  "notify_version": "3.8",
  "receiver_id": "27L7EUKFFCSPS",
  "business": "foo@bar.com",
  "payer_id": "W832M3A7B44MU",
  "verify_sign": "AaXhtpwght6PEuy-z7LFdf...",
  "mc_fee": "3.10",
  "mc_currency": "BRL",
  "shipping": "0.00",
  "payer_email": "foobar@gmail.com",
  "payment_type": "instant",
  "mc_gross": "39.00",
  "ipn_track_id": "f17a",
  "quantity": "1"
}

And this is the stacktrace:

Traceback (most recent call last):
  File "/home/cm/envs/cm/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
  File "/home/cm/envs/cm/local/lib/python2.7/site-packages/newrelic-2.28.0.26/newrelic/hooks/framework_django.py", line 496, in wrapper
  File "/home/cm/envs/cm/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 41, in inner
  File "/home/cm/envs/cm/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
  File "/home/cm/envs/cm/local/lib/python2.7/site-packages/paypal/standard/ipn/views.py", line 68, in ipn
  File "/home/cm/envs/cm/local/lib/python2.7/site-packages/paypal/standard/models.py", line 288, in set_flag
UnicodeDecodeError 'ascii' codec can't decode byte 0xc3 in position 102: ordinal not in range(128)

@stefanw
Copy link

stefanw commented Apr 20, 2015

I'm seeing this as well. It looks like a Unicode object (self.flag_info) is concatenated with a byte object info which contains non-ascii characters.

All assignments of flag here are byte objects and the last two may contain non-ascii characters. Not sure if this is the root cause though.

@rafaelks
Copy link

rafaelks commented May 9, 2015

@spookylukey Can you open this issue again? I'll try to look into it and fix.

@thiagogds
Copy link
Contributor

I'm having the same issue.
I looked it up and in fact it is two problems 😔

1st: UnicodeDecodeError
The problem and solution proposed by @stefanw is ok. When a form error have no-ascii characters we get the error. It was happening because my django is in pt-BR and my form errors have accents.

The real error in fact was that PayPal retry_at field was not in the PayPal date format.
I saw that many fields was already patched. I did a quick test adding retry_at in that list and it worked fine. But I didn't run any unit tests yet.

What do you guys think? I can send a PR later.

thiagogds added a commit to metapix/django-paypal that referenced this issue Jun 10, 2015
Some fields were not covered yet.
Issue spookylukey#26
@spookylukey
Copy link
Owner

The UnicodeDecodeError should have been addressed in 686382b

@spookylukey
Copy link
Owner

Both issues should now be addressed in 0.2.5

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

5 participants