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

Build fails when contributor list for file can't be fetched #19

Closed
jonaharagon opened this issue Sep 2, 2022 · 2 comments
Closed

Build fails when contributor list for file can't be fetched #19

jonaharagon opened this issue Sep 2, 2022 · 2 comments

Comments

@jonaharagon
Copy link

mkdocs build fails when this plugin can't access the contributors list for a file from GitHub's API. In this case it's because the file in question is from a submodule, so the file is not contained within the actual repo, but I would imagine this would also occur when adding any new file to the site which hasn't been uploaded to GitHub yet.

ERROR    -  HTTP error occurred: 404 Client Error: Not Found for url: https://github.com/privacyguides/privacyguides.org/contributors-list/main/docs/assets/brand/README.md
ERROR    -  Error building page 'assets/brand/README.md': local variable 'authors' referenced before assignment
Traceback (most recent call last):
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/mkdocs/__main__.py", line 192, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/mkdocs/commands/build.py", line 314, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/mkdocs/commands/build.py", line 212, in _build_page
    context = config['plugins'].run_event(
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/mkdocs_git_committers_plugin_2/plugin.py", line 98, in on_page_context
    authors, last_commit_date = self.list_contributors(git_path)
  File "/home/runner/.local/share/virtualenvs/privacyguides.org-YpGxi_ti/lib/python3.10/site-packages/mkdocs_git_committers_plugin_2/plugin.py", line 90, in list_contributors
    return authors, last_commit_date
UnboundLocalError: local variable 'authors' referenced before assignment
@jonaharagon
Copy link
Author

Can confirm this happens when adding any new file to the docs actually, despite the plugin recognizing the file has no git logs in this case:

INFO     -  Building documentation...
INFO     -  git-committers plugin ENABLED
INFO     -  Cleaning site directory
WARNING  -  [git-revision-date-localized-plugin] '/Users/jonah/GitHub/privacyguides.org/docs/new-page.md' has no git logs, using current timestamp
[. . .]
INFO     -  Fetching contributors for docs/new-page.md
ERROR    -  HTTP error occurred: 404 Client Error: Not Found for url: https://github.com/privacyguides/privacyguides.org/contributors-list/main/docs/new-page.md
ERROR    -  Error building page 'new-page.md': local variable 'authors' referenced before assignment
[. . .]

ojacques added a commit that referenced this issue Sep 2, 2022
Fix #19: do not fail if file is not on GitHub
@ojacques
Copy link
Owner

ojacques commented Sep 2, 2022

Thanks for the report @jonaharagon. Fixed in 1.0.2. I am not sure how submodules could be handled. So, I listed this as a limitation for now.

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