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

CLI crashes with AssertionError on Ubuntu 20.04 ARM64 #1365

Closed
Felixkruemel opened this issue May 27, 2021 · 19 comments · Fixed by #1399
Closed

CLI crashes with AssertionError on Ubuntu 20.04 ARM64 #1365

Felixkruemel opened this issue May 27, 2021 · 19 comments · Fixed by #1399
Milestone

Comments

@Felixkruemel
Copy link

Felixkruemel commented May 27, 2021

I can't get onionshare to work.
I've installed it in a python3-venv using python -m venv venv and activated the venv and then installed it using pip install onionshare-cli

The problem is that the help menu works with onionshare-cli --help but the actual sharing of e.g. a folder crashes with AssertionError: View function mapping is overwriting an existing endpoint function: static

I've got an natively running ARM64 Server running on Ubuntu 20.04. Also I want to point out that there are no snap packages for arm64 available like on many other projects. Maybe we could build them too.

@Felixkruemel
Copy link
Author

I now also tried the latest commit / dev build using the setup.py which still results in the same error. So it's not the pip build which is wrong ^^

@esskayesss
Copy link

Same on Archlinux 5.12.4-arch1-2

@Felixkruemel
Copy link
Author

@micahflee If you can't reproduce the error I'm open to help in regards of that. It's really crap that it won't launch at all :(

@whiskey01
Copy link

I have the same issue running Linux 5.12.2-arch1-1.

@whiskey01
Copy link

Here is the complete error:
OnionShare 2.2 | https://onionshare.org/ Traceback (most recent call last): File "/usr/bin/onionshare", line 22, in <module> onionshare.main() File "/usr/lib/python3.9/site-packages/onionshare/__init__.py", line 181, in main web = Web(common, False, mode) File "/usr/lib/python3.9/site-packages/onionshare/web/web.py", line 77, in __init__ self.generate_static_url_path() File "/usr/lib/python3.9/site-packages/onionshare/web/web.py", line 166, in generate_static_url_path self.app.add_url_rule( File "/usr/lib/python3.9/site-packages/flask/scaffold.py", line 56, in wrapper_func return f(self, *args, **kwargs) File "/usr/lib/python3.9/site-packages/flask/app.py", line 1092, in add_url_rule raise AssertionError( AssertionError: View function mapping is overwriting an existing endpoint function: static

@kpcyrd
Copy link

kpcyrd commented Jul 19, 2021

This issue is likely due to missing flask 2.0 support in onionshare.

@Danie10
Copy link

Danie10 commented Jul 26, 2021

Glad I'm not the only one - identical error on Manjaro KDE 5.13.4-1

@kpcyrd
Copy link

kpcyrd commented Jul 26, 2021

See #1385

@whiskey01
Copy link

Any way to resolve the error?

@zeronobody0
Copy link

I just involuntarily recreated the bug on Manjaro-OpenBox. I would like it if it were fixed.

@ghost
Copy link

ghost commented Aug 19, 2021

Same issue on Artix Linux 5.10.56-1-lts

@ghost
Copy link

ghost commented Aug 19, 2021

I created this patch and it seems to work, but I'm not sure if it is safe though. Anyone would like to try it ? Maybe I'll open a PR.
AssertionError.patch.gz

@micahflee micahflee added this to the 2.3.3 milestone Aug 20, 2021
@micahflee
Copy link
Collaborator

Fixed in #1392 1392

@kpcyrd
Copy link

kpcyrd commented Aug 21, 2021

The checks are still not passing with flask2 for onionshare 2.3.3:

==> Starting check()...
============================= test session starts ==============================
platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /build/onionshare/src/onionshare/cli/tests, configfile: pytest.ini
collected 253 items

cli/tests/test_cli.py ...                                                [  1%]
cli/tests/test_cli_common.py ........................................... [ 18%]
..................................................sss..........          [ 43%]
cli/tests/test_cli_settings.py ........sss.                              [ 47%]
cli/tests/test_cli_web.py .............................................. [ 66%]
........................................................................ [ 94%]
........FFsss                                                            [ 99%]
cli/tests/test_range_request.py .                                        [100%]

=================================== FAILURES ===================================
__________________ TestRangeRequests.test_if_unmodified_since __________________

self = <tests.test_cli_web.TestRangeRequests object at 0x7fd9200f2c40>
temp_dir = '/tmp/tmpwn8fsaca'
common_obj = <onionshare_cli.common.Common object at 0x7fd920351400>

    def test_if_unmodified_since(self, temp_dir, common_obj):
        web = web_obj(temp_dir, common_obj, "share", 3)
        web.settings.set("share", "autostop_sharing", False)
        url = "/download"
    
        with web.app.test_client() as client:
            headers = self._make_auth_headers(web.password)
            resp = client.get(url, headers=headers)
            assert resp.status_code == 200
            last_mod = resp.headers["Last-Modified"]
    
            headers.extend({"If-Unmodified-Since": last_mod})
>           resp = client.get(url, headers=headers)

cli/tests/test_cli_web.py:596: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.9/site-packages/werkzeug/test.py:1127: in get
    return self.open(*args, **kw)
/usr/lib/python3.9/site-packages/flask/testing.py:216: in open
    return super().open(  # type: ignore
/usr/lib/python3.9/site-packages/werkzeug/test.py:1072: in open
    response = self.run_wsgi_app(request.environ, buffered=buffered)
/usr/lib/python3.9/site-packages/werkzeug/test.py:943: in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
/usr/lib/python3.9/site-packages/werkzeug/test.py:1229: in run_wsgi_app
    app_rv = app(environ, start_response)
/usr/lib/python3.9/site-packages/flask/app.py:2088: in __call__
    return self.wsgi_app(environ, start_response)
/usr/lib/python3.9/site-packages/flask/app.py:2073: in wsgi_app
    response = self.handle_exception(e)
/usr/lib/python3.9/site-packages/flask/app.py:2070: in wsgi_app
    response = self.full_dispatch_request()
/usr/lib/python3.9/site-packages/flask/app.py:1515: in full_dispatch_request
    rv = self.handle_user_exception(e)
/usr/lib/python3.9/site-packages/flask/app.py:1513: in full_dispatch_request
    rv = self.dispatch_request()
/usr/lib/python3.9/site-packages/flask/app.py:1499: in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
cli/onionshare_cli/web/share_mode.py:197: in download
    range_, status_code = self.get_range_and_status_code(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'onionshare_cli.web.share_mode.ShareModeWeb'>, dl_size = 349
etag = '"sha256:d5e2c41b59eff5f6a4f2ca5c18c2d03ffafe797957b78e1ee128d64c3ad7b336"'
last_modified = datetime.datetime(2021, 8, 21, 12, 58, 9, 916692)

    @classmethod
    def get_range_and_status_code(cls, dl_size, etag, last_modified):
        use_default_range = True
        status_code = 200
        range_header = request.headers.get("Range")
    
        # range requests are only allowed for get
        if request.method == "GET":
            ranges = parse_range_header(range_header, dl_size)
            if not (
                len(ranges) == 1 and ranges[0][0] == 0 and ranges[0][1] == dl_size - 1
            ):
                use_default_range = False
                status_code = 206
    
            if range_header:
                if_range = request.headers.get("If-Range")
                if if_range and if_range != etag:
                    use_default_range = True
                    status_code = 200
    
        if use_default_range:
            ranges = [(0, dl_size - 1)]
    
        if len(ranges) > 1:
            abort(416)  # We don't support multipart range requests yet
        range_ = ranges[0]
    
        etag_header = request.headers.get("ETag")
        if etag_header is not None and etag_header != etag:
            abort(412)
    
        if_unmod = request.headers.get("If-Unmodified-Since")
        if if_unmod:
            if_date = parse_date(if_unmod)
>           if if_date and if_date > last_modified:
E           TypeError: can't compare offset-naive and offset-aware datetimes

cli/onionshare_cli/web/share_mode.py:291: TypeError
_________________ TestRangeRequests.test_firefox_like_behavior _________________

self = <tests.test_cli_web.TestRangeRequests object at 0x7fd92017a9a0>
temp_dir = '/tmp/tmpwn8fsaca'
common_obj = <onionshare_cli.common.Common object at 0x7fd92017a880>

    def test_firefox_like_behavior(self, temp_dir, common_obj):
        web = web_obj(temp_dir, common_obj, "share", 3)
        web.settings.set("share", "autostop_sharing", False)
        url = "/download"
    
        with web.app.test_client() as client:
            headers = self._make_auth_headers(web.password)
            resp = client.get(url, headers=headers)
            assert resp.status_code == 200
    
            # Firefox sends these with all range requests
            etag = resp.headers["ETag"]
            last_mod = resp.headers["Last-Modified"]
    
            # make a request that uses the full header set
            headers.extend(
                {
                    "Range": "bytes=0-10",
                    "If-Unmodified-Since": last_mod,
                    "If-Range": etag,
                }
            )
>           resp = client.get(url, headers=headers)

cli/tests/test_cli_web.py:621: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.9/site-packages/werkzeug/test.py:1127: in get
    return self.open(*args, **kw)
/usr/lib/python3.9/site-packages/flask/testing.py:216: in open
    return super().open(  # type: ignore
/usr/lib/python3.9/site-packages/werkzeug/test.py:1072: in open
    response = self.run_wsgi_app(request.environ, buffered=buffered)
/usr/lib/python3.9/site-packages/werkzeug/test.py:943: in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
/usr/lib/python3.9/site-packages/werkzeug/test.py:1229: in run_wsgi_app
    app_rv = app(environ, start_response)
/usr/lib/python3.9/site-packages/flask/app.py:2088: in __call__
    return self.wsgi_app(environ, start_response)
/usr/lib/python3.9/site-packages/flask/app.py:2073: in wsgi_app
    response = self.handle_exception(e)
/usr/lib/python3.9/site-packages/flask/app.py:2070: in wsgi_app
    response = self.full_dispatch_request()
/usr/lib/python3.9/site-packages/flask/app.py:1515: in full_dispatch_request
    rv = self.handle_user_exception(e)
/usr/lib/python3.9/site-packages/flask/app.py:1513: in full_dispatch_request
    rv = self.dispatch_request()
/usr/lib/python3.9/site-packages/flask/app.py:1499: in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
cli/onionshare_cli/web/share_mode.py:197: in download
    range_, status_code = self.get_range_and_status_code(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'onionshare_cli.web.share_mode.ShareModeWeb'>, dl_size = 349
etag = '"sha256:3c923f386247e4f5a4df545e7435798908eafa159779cd51a22fa992e51f873b"'
last_modified = datetime.datetime(2021, 8, 21, 12, 58, 10, 67805)

    @classmethod
    def get_range_and_status_code(cls, dl_size, etag, last_modified):
        use_default_range = True
        status_code = 200
        range_header = request.headers.get("Range")
    
        # range requests are only allowed for get
        if request.method == "GET":
            ranges = parse_range_header(range_header, dl_size)
            if not (
                len(ranges) == 1 and ranges[0][0] == 0 and ranges[0][1] == dl_size - 1
            ):
                use_default_range = False
                status_code = 206
    
            if range_header:
                if_range = request.headers.get("If-Range")
                if if_range and if_range != etag:
                    use_default_range = True
                    status_code = 200
    
        if use_default_range:
            ranges = [(0, dl_size - 1)]
    
        if len(ranges) > 1:
            abort(416)  # We don't support multipart range requests yet
        range_ = ranges[0]
    
        etag_header = request.headers.get("ETag")
        if etag_header is not None and etag_header != etag:
            abort(412)
    
        if_unmod = request.headers.get("If-Unmodified-Since")
        if if_unmod:
            if_date = parse_date(if_unmod)
>           if if_date and if_date > last_modified:
E           TypeError: can't compare offset-naive and offset-aware datetimes

cli/onionshare_cli/web/share_mode.py:291: TypeError
=============================== warnings summary ===============================
../../../../usr/lib/python3.9/site-packages/packaging/version.py:127: 426 warnings
  /usr/lib/python3.9/site-packages/packaging/version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
    warnings.warn(

../../../../usr/lib/python3.9/site-packages/dns/hash.py:23
  /usr/lib/python3.9/site-packages/dns/hash.py:23: DeprecationWarning: dns.hash module will be removed in future versions. Please use hashlib instead.
    warnings.warn(

../../../../usr/lib/python3.9/site-packages/dns/namedict.py:35
  /usr/lib/python3.9/site-packages/dns/namedict.py:35: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    class NameDict(collections.MutableMapping):

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED cli/tests/test_cli_web.py::TestRangeRequests::test_if_unmodified_since
FAILED cli/tests/test_cli_web.py::TestRangeRequests::test_firefox_like_behavior
============ 2 failed, 242 passed, 9 skipped, 428 warnings in 0.83s ============
==> ERROR: A failure occurred in check().

@easyteacher
Copy link
Contributor

The checks are still not passing with flask2 for onionshare 2.3.3:

#1399

@KamiMortem
Copy link

How was the problem solved? I keep getting the same problem with Archlinux kernel: 5.14.3-zen1-1-zen

Problem:

OnionShare 2.2 | https://onionshare.org/
Traceback (most recent call last):
File "/usr/bin/onionshare-gui", line 22, in
onionshare_gui.main()
File "/usr/lib/python3.9/site-packages/onionshare_gui/init.py", line 142, in main
gui = OnionShareGui(common, onion, qtapp, app, filenames, config, local_only)
File "/usr/lib/python3.9/site-packages/onionshare_gui/onionshare_gui.py", line 172, in init
self.share_mode.init()
File "/usr/lib/python3.9/site-packages/onionshare_gui/mode/share_mode/init.py", line 48, in init
self.web = Web(self.common, True, "share")
File "/usr/lib/python3.9/site-packages/onionshare/web/web.py", line 77, in init
self.generate_static_url_path()
File "/usr/lib/python3.9/site-packages/onionshare/web/web.py", line 166, in generate_static_url_path
self.app.add_url_rule(
File "/usr/lib/python3.9/site-packages/flask/scaffold.py", line 56, in wrapper_func
return f(self, *args, **kwargs)
File "/usr/lib/python3.9/site-packages/flask/app.py", line 1092, in add_url_rule
raise AssertionError(
AssertionError: View function mapping is overwriting an existing endpoint function: static

@mig5
Copy link
Collaborator

mig5 commented Sep 16, 2021

The fix has been fixed in git via the patch in #1399, but it has not yet made its way into an upcoming release. (Your output suggests you are still on OnionShare 2.2).

If you don't want to patch your own copy of the codebase in the meantime with that patch, you'll have to wait for a new release to come out that contains the fix.

@kpcyrd
Copy link

kpcyrd commented Sep 16, 2021

Could a new release be created? There are other important fixes too. :)

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

Successfully merging a pull request may close this issue.