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

Internal Server Error on CTFd 3.7.3 #92

Open
hiisukun opened this issue Sep 6, 2024 · 6 comments
Open

Internal Server Error on CTFd 3.7.3 #92

hiisukun opened this issue Sep 6, 2024 · 6 comments

Comments

@hiisukun
Copy link

hiisukun commented Sep 6, 2024

Hey team -- I cloned core-beta from main today, ran yarn build without issue, but when I put the theme in a fresh CTFd:3.7.3 container I get "Internal Server Error" when loading the CTFd instance root/homepage.

The container log shows TypeError: _AssetsWrapper.js() got an unexpected keyword argument 'type'.

Any suggestions? I'd like to use a CTFd 'release' that is tagged, so if there is an older core-beta commit I need to work from that might be fine.

Here's the full log:

ERROR [CTFd] Exception on / [GET]
Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask_restx/api.py", line 674, in error_router
    return original_handler(e)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/CTFd/CTFd/views.py", line 403, in static_html
    return render_template("page.html", content=page.html, title=page.title)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/templating.py", line 147, in render_template
    return _render(
           ^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/templating.py", line 128, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/opt/venv/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/CTFd/CTFd/themes/core-beta-build/templates/page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/opt/CTFd/CTFd/themes/core-beta-build/templates/base.html", line 17, in top-level template code
    {{ Assets.js("assets/js/color_mode_switcher.js", type=None) }}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: _AssetsWrapper.js() got an unexpected keyword argument 'type'
[2024-09-06 22:52:16 +0000] [27] [ERROR] Error handling request /
Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask_restx/api.py", line 674, in error_router
    return original_handler(e)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/CTFd/CTFd/views.py", line 403, in static_html
    return render_template("page.html", content=page.html, title=page.title)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/templating.py", line 147, in render_template
    return _render(
           ^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/templating.py", line 128, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/opt/venv/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/CTFd/CTFd/themes/core-beta-build/templates/page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/opt/CTFd/CTFd/themes/core-beta-build/templates/base.html", line 17, in top-level template code
    {{ Assets.js("assets/js/color_mode_switcher.js", type=None) }}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: _AssetsWrapper.js() got an unexpected keyword argument 'type'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base_async.py", line 55, in handle
    self.handle_request(listener_name, req, client, addr)
  File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/ggevent.py", line 127, in handle_request
    super().handle_request(listener_name, req, sock, addr)
  File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 2091, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 2076, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask_restx/api.py", line 674, in error_router
    return original_handler(e)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 1440, in handle_exception
    server_error = self.ensure_sync(handler)(server_error)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/CTFd/CTFd/errors.py", line 14, in render_error
    render_template(
  File "/opt/venv/lib/python3.11/site-packages/flask/templating.py", line 147, in render_template
    return _render(
           ^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/templating.py", line 128, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/opt/venv/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/CTFd/CTFd/themes/core-beta-build/templates/errors/500.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/opt/CTFd/CTFd/themes/core-beta-build/templates/base.html", line 17, in top-level template code
    {{ Assets.js("assets/js/color_mode_switcher.js", type=None) }}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: _AssetsWrapper.js() got an unexpected keyword argument 'type'
 * Loaded module, <module 'CTFd.plugins.challenges' from '/opt/CTFd/CTFd/plugins/challenges/__init__.py'>
 * Loaded module, <module 'CTFd.plugins.dynamic_challenges' from '/opt/CTFd/CTFd/plugins/dynamic_challenges/__init__.py'>
 * Loaded module, <module 'CTFd.plugins.flags' from '/opt/CTFd/CTFd/plugins/flags/__init__.py'>
10.88.0.9 - - [06/Sep/2024:22:52:16 +0000] "GET / HTTP/1.1" 500 0 "-" "-"
@hiisukun
Copy link
Author

hiisukun commented Sep 6, 2024

I will note that using the core-beta that shipped with 3.7.3 works fine -- but changing to core-beta-built-today in the admin selection panel causes the above crash. Switching back to the built-in corrects it straight away, and I can use the CTFd instance without issue.

@ColdHeat
Copy link
Member

ColdHeat commented Sep 6, 2024

@hiisukun Very recent change that has not shipped in a proper release yet CTFd/CTFd@ac8c46d

We could issue a 3.7.4 release but I think it would be better for you to work off of CTFd master because this light/dark theme change has not really baked a lot.

Alternatively you could remove this line: https://github.com/CTFd/core-beta/blob/main/templates/base.html#L17 and inline the code as shown here: 81c8774#diff-690b81fad8df2a1f1ce37c846641d9247e3472d244f17039d2910a5ed0c98d5e

@hiisukun
Copy link
Author

hiisukun commented Sep 7, 2024

Excellent, thanks @ColdHeat - that worked a charm. I think it resulted in my CTFd being in dark-mode (though it's night time here..) but that's no issue.

Is the color_mode_switcher.js and theme work stable? I might be happy to cherry pick that to our 3.7.3 event, if the CTFd changes are just that assets.py.

And thanks for the fast reply! : )

@ColdHeat
Copy link
Member

ColdHeat commented Sep 7, 2024

I think there are some rough edges with dark mode but it works well enough. Aside from the assets.py change there's nothing in it that should cause any breakages.

@hiisukun
Copy link
Author

hiisukun commented Oct 4, 2024 via email

@ColdHeat
Copy link
Member

ColdHeat commented Oct 4, 2024 via email

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

No branches or pull requests

2 participants