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

Value Error on 'New Application' in /account/settings/applications/ #2929

Open
Samk13 opened this issue Nov 29, 2024 · 0 comments · May be fixed by inveniosoftware/invenio-oauth2server#267
Open
Labels
bug Something isn't working

Comments

@Samk13
Copy link
Member

Samk13 commented Nov 29, 2024

Package version (if known): 13.0.0b1.dev18, V12

Describe the bug

Click new Application will result in ValueError: too many values to unpack (expected 3)

Steps to Reproduce

  1. Go to /account/settings/applications/
  2. Click on '+ New Application'
  3. See error

Expected behavior

Screenshots (if applicable)

127.0.0.1 - - [29/Nov/2024 13:58:37] "GET /account/settings/applications/clients/new/ HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/app.py", line 2552, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/werkzeug/middleware/proxy_fix.py", line 187, in __call__
    return self.app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/werkzeug/middleware/dispatcher.py", line 78, in __call__
    return app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/app.py", line 2532, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask_login/utils.py", line 290, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_oauth2server/views/settings.py", line 145, in client_new
    return render_template(
           ^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/templating.py", line 147, in render_template
    return _render(app, template, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/flask/templating.py", line 130, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_oauth2server/templates/semantic-ui/invenio_oauth2server/settings/client_new.html", line 13, in top-level template code
    {%- from "invenio_oauth2server/settings/_macros.html" import render_field with context %}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_oauth2server/templates/semantic-ui/invenio_oauth2server/settings/index.html", line 13, in top-level template code
    {%- import "invenio_oauth2server/settings/helpers.html" as helpers with context %}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_theme/templates/semantic-ui/invenio_theme/page_settings.html", line 15, in top-level template code
    {%- set title = _("Settings") %}
  File "/home/user/INVENIO/issues/invenio-app-rdm/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/page.html", line 11, in top-level template code
    {%- extends "invenio_theme/page.html" -%}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_theme/templates/semantic-ui/invenio_theme/page.html", line 86, in top-level template code
    {%- block body %}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_theme/templates/semantic-ui/invenio_theme/page.html", line 97, in block 'body'
    {%- block body_inner %}
  File "/home/user/INVENIO/issues/invenio-app-rdm/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/page.html", line 21, in block 'body_inner'
    {%- block page_body %}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_theme/templates/semantic-ui/invenio_theme/page_settings.html", line 51, in block 'page_body'
    {%- block settings_content scoped %}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_oauth2server/templates/semantic-ui/invenio_oauth2server/settings/client_new.html", line 23, in block 'settings_content'
    {{ render_field(field) }}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_oauth2server/templates/semantic-ui/invenio_oauth2server/settings/_macros.html", line 22, in template
    {{ field(placeholder=_(field.label.text | string), **extras) }}
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/wtforms/fields/core.py", line 176, in __call__
    return self.meta.render_field(self, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/wtforms/meta.py", line 64, in render_field
    return field.widget(field, **render_kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/werkzeug/local.py", line 570, in <lambda>
    __call__ = _ProxyLookup(lambda self, *args, **kwargs: self(*args, **kwargs))
                                                          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.6/envs/latest-build/lib/python3.12/site-packages/invenio_oauth2server/theme/semantic/form_styling.py", line 29, in __call__
    for val, label, selected in field.iter_choices():
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)

Extra

Looks like adding extra , _ to the unpacked values in iter_choices() fix the issue here

        for val, label, selected, _ in field.iter_choices():
            if selected:
                default_text_html = [
                    '<div aria-atomic="true" aria-live="polite" class="text">{0}</div><div class="menu">'.format(
                        label
                    )
                ]
            items_html.append(self.render_option(val, label, selected))

see: https://wtforms.readthedocs.io/en/3.2.x/widgets/#wtforms.widgets.Select:~:text=value%2C%20label%2C%20selected%2C-,render_kw,-).%20It%20also

next(field.iter_choices())
('True', l'Confidential', True, {})
@Samk13 Samk13 added the bug Something isn't working label Nov 29, 2024
Samk13 added a commit to Samk13/invenio-oauth2server that referenced this issue Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant