Skip to content

Eve broken with werzeug >= 0.15.3 #1267

Closed
wangsha/eve
#1

Description

@sunbit

I actually realized of this when tests failed from a PR i was preparing, and then tests on travis also failed. After some debugging i tracked down the error to werkzeug, and to this particular change referenced in this issue

pallets/werkzeug#1516
pallets/werkzeug@4ee2464

If i understant correctly, they are fixing something that was not right, but it breaks the expected value format of exceptions www_authenticate parameter here:

https://github.com/pyeve/eve/blob/master/eve/endpoints.py#L173:L174

were eve was expecting a (None,) when now it's simply None.

I'm not sure if this should be considered something wrong on werkzeug's side for changing that behavoir and file a bug there, or fix such assumption in eve.

What do you think?


Expected Behavior

Test pass in any environment

Actual Behavior

Auth tests fail when using werkzeug >=0.15.3

======================================================== test session starts ========================================================
platform darwin -- Python 2.7.16, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
cachedir: .tox/py27/.pytest_cache
rootdir: /private/tmp/eve, inifile: pytest.ini
collected 796 items                                                                                                                 

eve/tests/auth.py .....F....F

============================================================= FAILURES ==============================================================
____________________________________________ TestBasicAuth.test_authorized_media_access _____________________________________________

self = <eve.tests.auth.TestBasicAuth testMethod=test_authorized_media_access>

    def test_authorized_media_access(self):
        self.app.config["RETURN_MEDIA_AS_BASE64_STRING"] = False
        self.app.config["RETURN_MEDIA_AS_URL"] = True
        self.app.config["BANDWIDTH_SAVER"] = False
        self.app._init_media_endpoint()
    
        clean = b"my new file contents"
        test_field, test_value = "ref", "9234567890123456789054321"
        data = {"media": (BytesIO(clean), "test.txt"), test_field: test_value}
        r, s = self.parse_response(
            self.test_client.post(
                self.known_resource_url, data=data, headers=self.valid_media_auth
            )
        )
        self.assert201(s)
    
        file_url = r["media"]
        r = self.test_client.get(file_url, headers=self.invalid_auth)
>       self.assert401(r.status_code)

eve/tests/auth.py:155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
eve/tests/__init__.py:339: in assert401
    self.assertEqual(status, 401)
E   AssertionError: 500 != 401
--------------------------------------------------------- Captured log call ---------------------------------------------------------
ERROR    flask.app:app.py:1761 Exception on /media/5cdc2983d9d4670e2cbf4687 [GET]
Traceback (most recent call last):
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 1713, in handle_user_exception
    return self.handle_http_exception(e)
  File "/private/tmp/eve/.tox/py27/lib/python2.7/site-packages/flask/app.py", line 1644, in handle_http_exception
    return handler(e)
  File "/private/tmp/eve/eve/endpoints.py", line 182, in error_endpoint
    return send_response(None, (response, None, None, error.code, headers))
  File "/private/tmp/eve/eve/render.py", line 52, in decorated
    r = f(*args, **kwargs)
  File "/private/tmp/eve/eve/render.py", line 92, in send_response
    return _prepare_response(resource, *response if response else [None])
  File "/private/tmp/eve/eve/render.py", line 164, in _prepare_response
    for header, value in headers:
TypeError: 'NoneType' object is not iter

Environment

  • Python version: any python version
  • Eve version: master

Activity

  1. added a commit that references this issue on May 16, 2019
  2. added this to the milestone on May 16, 2019
  3. nicolaiarocci commented on May 16, 2019

    @nicolaiarocci
    Member

    They sure have been playing around a lot with that Unauthorized thing. 0.15.1 broke it, and now 0.15.3 does it again 😄 I have pinned Werkzeug to 0.15.3 for the time being. We'll see if their API stabilizes over time.

  4. modified the milestones: , 0.9.1 on May 16, 2019
  5. added a commit that references this issue on Mar 24, 2024
    cf9c853
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions