jackm / kijiji-manager

App for viewing, posting, reposting, and deleting your Kijiji ads
https://pypi.org/project/kijiji-manager/
MIT License
52 stars 11 forks source link

Error: "Unable to parse text: mismatched tag" - When Logging-in #64

Open jerry2key opened 1 year ago

jerry2key commented 1 year ago

Today, out of random I started getting "Unable to parse text: mismatched tag" errors when trying to log into kijiji accounts.

Tried changing IP address, issue persists.

On your end, try logging-out from your kijiji account in the app and then log back in. Do you get the same error?

Possibly it could be related to new login page kijiji has lunched. I ran a debugger and here's the result AttributeError: 'AnonymousUserMixin' object has no attribute 'id'

jackm commented 1 year ago

This is likely a problem with your Kijiji account - it may have been flagged for abuse and disabled. See comment in #54, #49, and #50

Possibly it could be related to new login page kijiji has lunched. I ran a debugger and here's the result AttributeError: 'AnonymousUserMixin' object has no attribute 'id'

This error is a result of your user not being logged in on the kijiji-manager app, but it tried loading a page that requires (and assumes) that you be logged in, which shouldn't be possible. Could you tell me the steps to reproduce this?

jerry2key commented 1 year ago

@jackm Ok, I did some troubleshooting. I tried multiple computers with kijiji app installed, just to rule out any conflicts.

Basically, when I am using 0.2.2. version of the app, when trying to log into ANY kijiji account that I was able to log into previously, I get this error "Unable to parse text: mismatched tag". When I create a new account on kijiji and try to login, I am able to log in via app, but the moment I log out and try to log in once again, I get the "Unable to parse text: mismatched tag" error.

NEXT upgraded to versions 0.2.3 and then enable the debugger, and once again when I try to log-in from any of the accounts (except brand new account) I get: AttributeError: 'AnonymousUserMixin' object has no attribute 'id'

Basically, it seems as if once the account has been used to once to log into the app, it cannot be used again to log back in. I tried multiple computers with the app running. The best method of trying to get the error, is by logging in and logging out MULTIPLE times from the app.

Accounts are not restricted on the kijiji site itself.

aibosss commented 1 year ago

I found this happen when using a VPN IP

jerry2key commented 1 year ago

@jackm I figured that if you try log in and log out in the app for 3 -4 times in a row it will lock out account for a period of 12- 24 hours.

Please close the issue.

amranwali commented 1 year ago

I am getting the same error as jerry2key. The program will work for a few days but then I get the same login error for a few days. After a few days the login error will disappear.

thanksforkijijimanager commented 1 year ago

Getting this same issue now, has not happened to me until now

raise KijijiApiXmlException(f"Unable to parse text: {errors.messages[e.code]}", text)

File "/home/user/.local/lib/python3.8/site-packages/kijiji_manager/kijijiapi.py", line 27, in init user_dir = os.path.join(current_app.instance_path, 'user', current_user.id) AttributeError: 'AnonymousUserMixin' object has no attribute 'id'

dudududodododedede commented 11 months ago

Same issue occuring here. No problem when logging into the account via browser


Traceback (most recent call last):
  File "/home/bob/kijiji-manager/kijiji_manager/kijijiapi.py", line 422, in _parse_response
    doc = xmltodict.parse(text)
  File "/home/bob/kijiji-manager/venv/lib/python3.10/site-packages/xmltodict.py", line 378, in parse
    parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: mismatched tag: line 5, column 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bob/kijiji-manager/venv/lib/python3.10/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/bob/kijiji-manager/venv/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/bob/kijiji-manager/venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/bob/kijiji-manager/venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/bob/kijiji-manager/kijiji_manager/views/user.py", line 27, in login
    user_id, token = kijiji_api.login(email, password)
  File "/home/bob/kijiji-manager/kijiji_manager/kijijiapi.py", line 94, in login
    doc = self._parse_response(r.text)
  File "/home/bob/kijiji-manager/kijiji_manager/kijijiapi.py", line 424, in _parse_response
    raise KijijiApiXmlException(f"Unable to parse text: {errors.messages[e.code]}", text)
  File "/home/bob/kijiji-manager/kijiji_manager/kijijiapi.py", line 27, in __init__
    user_dir = os.path.join(current_app.instance_path, 'user', current_user.id)
AttributeError: 'AnonymousUserMixin' object has no attribute 'id'
127.0.0.1 - - [15/Dec/2023 16:28:41] "POST /login HTTP/1.1" 500 -```
dudududodododedede commented 11 months ago

Hmm tried a few more times after 5 minutes and kijiji-manager started working. Not sure what the pattern is. This is an account that's 5+ years old

haal-laah commented 11 months ago

Just encountered this issue and was able to sign in when using a VPN.

dudududodododedede commented 11 months ago

A day later and I got this same error. I clicked logout in kijiji-manager, then tried logging in again. This is what I see in the interactive debugger console, doing a dump of the text variable since it seems to crash in _parse_response while attempting doc = xmltodict.parse(text)

Traceback (most recent call last)
File "/home/bob/kijiji-manager/kijiji_manager/kijijiapi.py", line 422, in _parse_response
doc = xmltodict.parse(text)
[console ready]
>>> dump(text)
Details for str object at 0x7f7888671230
'\n<html><head>\n<meta http-equiv="content-type" content="text/html;charset=utf-8">\n<title>502 Server Error</title>\n</head>\n<body text=#000000 bgcolor=#ffffff>\n<h1>Error: Server Error</h1>\n<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>\n<h2></h2>\n</body></html>\n'str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'."  
dudududodododedede commented 11 months ago

This is the contents of the uuid xml file in the instance folder:


<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>
jackm commented 11 months ago

This is the contents of the uuid xml file in the instance folder:


<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>

This is helpful, thank you.

The Kijiji site is responding to the API request with non-XML content (even though the kijiji-manager client specifically told it that it would only accept XML) showing an HTTP 502 error. Since this appears to be happening with the login API endpoint it could be some kind of rate limiting that Kijiji is doing.

I personally have never encountered problems logging in or out, but I also do that very seldomly. I basically login once, and then only login again when the cookie eventually expires and I am forcefully logged out.

haal-laah commented 11 months ago

Getting the 502 error with any Kijiji account now, regardless of a VPN being used.

dudududodododedede commented 11 months ago

This is the contents of the uuid xml file in the instance folder:


<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>

This is helpful, thank you.

The Kijiji site is responding to the API request with non-XML content (even though the kijiji-manager client specifically told it that it would only accept XML) showing an HTTP 502 error. Since this appears to be happening with the login API endpoint it could be some kind of rate limiting that Kijiji is doing.

I personally have never encountered problems logging in or out, but I also do that very seldomly. I basically login once, and then only login again when the cookie eventually expires and I am forcefully logged out.

One thing to note is that this error happens not just upon login i.e. I was finally able to login this morning and it worked for a few hours, but now when I come back to kijiji-manager I see this error:

Screenshot 2023-12-17 181053

So it seem that existing sessions are affected as well (not just the creation of new sessions upon login)

I guess kijiji is doing some kind of throttling to their APIs for some accounts. I haven't been able to narrow down any kind of pattern (I tried using a VPN and the experience was the same). Anecdotally, it seems like this errors occur more often in the evening (Eastern Time), whereas morning time seems to be mostly OK

haal-laah commented 11 months ago

This is the contents of the uuid xml file in the instance folder:


<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>

This is helpful, thank you. The Kijiji site is responding to the API request with non-XML content (even though the kijiji-manager client specifically told it that it would only accept XML) showing an HTTP 502 error. Since this appears to be happening with the login API endpoint it could be some kind of rate limiting that Kijiji is doing. I personally have never encountered problems logging in or out, but I also do that very seldomly. I basically login once, and then only login again when the cookie eventually expires and I am forcefully logged out.

One thing to note is that this error happens not just upon login i.e. I was finally able to login this morning and it worked for a few hours, but now when I come back to kijiji-manager I see this error:

Screenshot 2023-12-17 181053

So it seem that existing sessions are affected as well (not just the creation of new sessions upon login)

I guess kijiji is doing some kind of throttling to their APIs for some accounts. I haven't been able to narrow down any kind of pattern (I tried using a VPN and the experience was the same). Anecdotally, it seems like this errors occur more often in the evening (Eastern Time), whereas morning time seems to be mostly OK

I encountered the same error. I think the only way to relieve this issue is to setup a fallback API through BeautifulSoup or something similar until the Mingle API decides to work again.

aibosss commented 7 months ago

Started getting this too, not able to login anymore. Mingle Down? Maybe someone can get the new API urls trough some m i t m tactics with the mobile app..

adm-gis commented 7 months ago

Yup. Same here. I originally thought it was the VPN, but it wasn't. image

thanksforkijijimanager commented 7 months ago

hasnt worked in a long time for me

On Fri, Apr 26, 2024 at 10:08 AM Adam McKay @.***> wrote:

Yup. Same here. I originally thought it was the VPN, but it wasn't. image.png (view on web) https://github.com/jackm/kijiji-manager/assets/71985981/556003e2-3263-430e-b030-566549f02e12

— Reply to this email directly, view it on GitHub https://github.com/jackm/kijiji-manager/issues/64#issuecomment-2079469560, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW2MOUY2DJLQFTXE3Q7KFRDY7JNVDAVCNFSM6AAAAAA5RULQ72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZZGQ3DSNJWGA . You are receiving this because you commented.Message ID: @.***>

jackm commented 6 months ago

See #67 for the root cause of the most recent reports of this bug