fedora-infra / mirrormanager2

Rewrite of the MirrorManager application in Flask and SQLAlchemy
https://mirrormanager.fedoraproject.org
GNU General Public License v2.0
65 stars 49 forks source link

Error with Login through MirrorManager2. TypeError? #255

Open DanielTimLee opened 6 years ago

DanielTimLee commented 6 years ago

I'm not sure why I'm experiencing this issue.

Environment Fedora 28 Vagrant Box (Used other Vagrant Box, not using default one)

QEMU 3.0.0 libvirt 4.7.0 Vagrant 2.1.4 Linux 4.14.71-1

Steps to Reproduce.

  1. Follow Hacking with Vagrant, Steps. 1-4
  2. Open http://0.0.0.0:5000/
  3. Login with FAS Id.
  4. Authorize OpenID
  5. Boom! -> TypeError: frozenset([u'']) is not JSON serializable

Debug Messages

INFO:werkzeug:192.168.121.144 - - [02/Oct/2018 14:13:02] "GET / HTTP/1.1" 200 -
INFO:werkzeug:192.168.121.144 - - [02/Oct/2018 14:13:02] "GET /static/mirrormanager2.css HTTP/1.1" 200 -
INFO:werkzeug:192.168.121.144 - - [02/Oct/2018 14:13:02] "GET /static/mirrormanager-logo.png HTTP/1.1" 200 -
INFO:werkzeug:192.168.121.144 - - [02/Oct/2018 14:13:02] "GET /static/jquery-1.11.2.min.js HTTP/1.1" 200 -
Generated checkid_setup request to https://id.fedoraproject.org/openid/ using stateless mode.
INFO:werkzeug:192.168.121.144 - - [02/Oct/2018 14:13:33] "GET /login?next=http://0.0.0.0:5000/ HTTP/1.1" 200 -
No pre-discovered information supplied.
Performing discovery on http://myID.id.fedoraproject.org/
Received id_res response from https://id.fedoraproject.org/openid/ using association {HMAC-SHA1}{5bb37d0e}{TCEVUQ==}
Using OpenID check_authentication
assoc_handle
ax.count.ext0
ax.count.ext1
ax.mode
ax.type.ext0
ax.type.ext1
cla.signed_cla
claimed_id
identity
lp.is_member
mode
ns
ns.ax
ns.cla
ns.lp
ns.sreg
op_endpoint
response_nonce
return_to
signed
sreg.email
sreg.fullname
sreg.nickname
sreg.timezone
INFO:werkzeug:192.168.121.144 - - [02/Oct/2018 14:13:38] "GET /_flask_fas_openid_handler/? <some_personal_request> HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1816, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1833, in finalize_request
    response = self.process_response(response)
  File "/usr/lib64/python2.7/site-packages/flask/app.py", line 2114, in process_response
    self.session_interface.save_session(self, ctx.session, response)
  File "/usr/lib64/python2.7/site-packages/flask/sessions.py", line 375, in save_session
    val = self.get_signing_serializer(app).dumps(dict(session))
  File "/usr/lib/python2.7/site-packages/itsdangerous.py", line 565, in dumps
    payload = want_bytes(self.dump_payload(obj))
  File "/usr/lib/python2.7/site-packages/itsdangerous.py", line 847, in dump_payload
    json = super(URLSafeSerializerMixin, self).dump_payload(obj)
  File "/usr/lib/python2.7/site-packages/itsdangerous.py", line 550, in dump_payload
    return want_bytes(self.serializer.dumps(obj))
  File "/usr/lib64/python2.7/site-packages/flask/json/tag.py", line 296, in dumps
    return dumps(self.tag(value), separators=(',', ':'))
  File "/usr/lib64/python2.7/site-packages/flask/json/__init__.py", line 179, in dumps
    rv = _json.dumps(obj, **kwargs)
  File "/usr/lib64/python2.7/json/__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
    o = _default(o)
  File "/usr/lib64/python2.7/site-packages/flask/json/__init__.py", line 81, in default
    return _json.JSONEncoder.default(self, o)
  File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: frozenset([u'']) is not JSON serializable
DanielTimLee commented 6 years ago

Nope. Fedora version wasn't the problem.

Just tested with Fedora 23 Libvirt Box. And experience same error.

adrianreber commented 5 years ago

@puiterwijk any ideas what to do about this?

sinnykumari commented 5 years ago

Seeing similar error message while running locally using virtualenv from current master

shailysangwan commented 5 years ago

Hi, @adrianreber @DanielTimLee The latest release version for python-fedora using pip is 0.10.0 which does not include the latest commits in the repository. You get this error because the default json encoder for your application likely does not handle the frozenset type. Updating the json encoder so that it is able to do so is dependent on the flask version used by your application. You can fix this by locally copying the flask_fas_openid module from the repository's source code and importing FAS from this module instead. ( You can refer to https://github.com/fedora-infra/python-fedora/commit/4719f10b3af1cf068e969387eab7df7e935003cd for a better idea )