cristoper / feedmixer

A self-hosted API to fetch and mix entries from Atom and RSS feeds (returns Atom, RSS, or JSON)
Do What The F*ck You Want To Public License
168 stars 10 forks source link

ValueError: invalid literal for int() with base 10 #16

Closed MrGeorgen closed 3 years ago

MrGeorgen commented 3 years ago

I get the following error:

[2021-01-29 15:52:14 +0100] [22341] [INFO] Starting gunicorn 20.0.4
[2021-01-29 15:52:14 +0100] [22341] [INFO] Listening at: http://127.0.0.1:8000 (22341)
[2021-01-29 15:52:14 +0100] [22341] [INFO] Using worker: sync
[2021-01-29 15:52:14 +0100] [22346] [INFO] Booting worker with pid: 22346
[2021-01-29 15:52:17 +0100] [22346] [ERROR] Error handling request /atom?n=0%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D15%3Fu%3Dcristoper%3Fp%3Dfeedmixer%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D13%3Fu%3Dcristoper%3Fp%3Dfeedmixer%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D3564%3Fu%3Ddense-analysis%3Fp%3Dale%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D192%3Fu%3Dthemoonisacheese%3Fp%3D2bored2wait%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D189%3Fu%3Dthemoonisacheese%3Fp%3D2bored2wait%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D194%3Fu%3Dthemoonisacheese%3Fp%3D2bored2wait%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D190%3Fu%3Dthemoonisacheese%3Fp%3D2bored2wait%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D191%3Fu%3Dthemoonisacheese%3Fp%3D2bored2wait%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D193%3Fu%3Dthemoonisacheese%3Fp%3D2bored2wait%3Fformat%3DAtom%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D339%3Fu%3DFabricMC%3Fp%3Dfabric-loom%3Fformat%3DAtom
Traceback (most recent call last):
  File "/home/mrgeorgen/.local/share/virtualenvs/feedmixer-rEvpsW94/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 134, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/mrgeorgen/.local/share/virtualenvs/feedmixer-rEvpsW94/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/home/mrgeorgen/dev/python/feedmixer/feedmixer_wsgi.py", line 64, in application
    return api(environ, start_response)
  File "/home/mrgeorgen/.local/share/virtualenvs/feedmixer-rEvpsW94/lib/python3.9/site-packages/falcon/api.py", line 269, in __call__
    responder(req, resp, **params)
  File "/home/mrgeorgen/dev/python/feedmixer/feedmixer_api.py", line 114, in on_get
    feeds, n, full = parse_qs(req)
  File "/home/mrgeorgen/dev/python/feedmixer/feedmixer_api.py", line 84, in parse_qs
    return ParsedQS(feeds, int(n), bool(full))
ValueError: invalid literal for int() with base 10: '0?f=https://rss.nixnet.services/index.php?action=display?bridge=GithubIssue?context=Issue comments?i=15?u=cristoper?p=feedmixer?format=Atom?f=https://rss.nixnet.services/index.php?action=display?brid

after running a shell script curl 'https://github.com/search?o=desc&q=involves%3AMrGeorgen&s=updated' | github-issue-search gihtub-issue-search script:

#!/bin/sh
feeds=`grep -Po '(?<=href=")[^"]*' < /dev/stdin |uniq -u |awk -F / '{ if($4 == "issues" || $4 == "pull") { printf "%s", "%3Ff%3Dhttps%3A%2F%2Frss.nixnet.services%2Findex.php%3Faction%3Ddisplay%3Fbridge%3DGithubIssue%3Fcontext%3DIssue+comments%3Fi%3D"$5"%3Fu%3D"$2"%3Fp%3D"$3"%3Fformat%3DAtom"} }'`
curl "http://localhost:8000/atom?n=0$feeds"

I'm not sure if my script passes unexpected parameters. If so feedmixer should print a proper error message which parameter is the problem

MrGeorgen commented 3 years ago

bruh don't mind of curse the ? before the f don't need to be escaped. the python error message is also enough, no need for a custom one

cristoper commented 3 years ago

Thanks! I added a small patch to catch exceptions when parsing n and add a more specific error to the stack trace in case that helps future users figure out where the problem is more quickly.