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

Bug in 2.4.0: UnboundLocalError: cannot access local variable 'user' where it is not associated with a value #72

Closed
gusttt opened this issue Oct 3, 2024 · 2 comments

Comments

@gusttt
Copy link

gusttt commented Oct 3, 2024

Hello,

Thank you for your plugin ❤️

When using the just released 2.4.0 version, the github action fails with the below error. When using version 2.3.0 the error does not occur.

INFO    -  git-committers: fetching contributors for docs/index.md
ERROR   -  Error building page 'index.md': cannot access local variable 'user' where it is not associated with a value
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.6/x64/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs/__main__.py", line 311, in gh_deploy_command
    build.build(cfg, dirty=not clean)
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs/commands/build.py", line 337, in build
    _build_page(
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs/commands/build.py", line 213, in _build_page
    context = config.plugins.on_page_context(context, page=page, config=config, nav=nav)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs/plugins.py", line 643, in on_page_context
    return self.run_event('page_context', context, page=page, config=config, nav=nav)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs/plugins.py", line 566, in run_event
    result = method(item, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs_git_committers_plugin_2/plugin.py", line 287, in on_page_context
    authors, last_commit_date = self.list_contributors(git_path)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs_git_committers_plugin_2/plugin.py", line 267, in list_contributors
    authors = self.get_contributors_to_file(path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/mkdocs_git_committers_plugin_2/plugin.py", line 121, in get_contributors_to_file
    'avatar': commit['author']['avatar_url'] if user['avatar_url'] is not None else ''
                                                ^^^^
UnboundLocalError: cannot access local variable 'user' where it is not associated with a value
Error: Process completed with exit code 1.
@ricolxwz
Copy link

ricolxwz commented Oct 4, 2024

+1

@ojacques
Copy link
Owner

ojacques commented Oct 4, 2024

Fixed by #73

@ojacques ojacques closed this as completed Oct 4, 2024
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

3 participants