Mkdocs-material: Regression: Hide GitHub Stats for Private Repositories

Created on 1 Dec 2020  ·  3Comments  ·  Source: squidfunk/mkdocs-material

__I've found a bug and checked that ...__

  • [x] ... the problem doesn't occur with the default MkDocs template
  • [x] ... the problem is not in any of my customizations (CSS, JS, template)
  • [ ] ... the documentation does not mention anything about my problem (it confirms it -- see below)
  • [ ] ... there are no open or closed issues that are related to my problem (there is a closed issue that I think is related -- see below)

Description

This bug concerns the visibility of the X Stars • X Forks statistic.

I am wondering if the behavior change resulted from the fix for #1864.

Expected behavior

Previously (we had been on 5.1.0), the stats were hidden for private repositories -- only the GitHub logo was shown. This is confirmed to be expected by the docs:

Additionally, for GitHub and GitLab, the number of stars and forks is automatically requested and rendered for _public repositories_.

(Emphasis in original) [link]

Actual behavior

Now, 0 Stars • 0 Forks is shown when given a private repository (regardless of the actual number of stars or forks).

Steps to reproduce the bug

  1. Provide a value for repo_url that points at a private GitHub repository (or a nonexistent repo).
  2. Build and serve the site.
  3. Browser: clear session storage.
  4. Navigate to the site with the console open.
  5. Observe a GitHub API request sent for the repo; for a private repo, GH returns a 404.
  6. Observe that the GitHub icon has "0 Stars 0 Forks" underneath it.
  7. Observe in session storage, the following value is set: ["0 Stars","0 Forks"].

Package versions

  • Python: 2.7.4
  • MkDocs: 1.1.2
  • Material: 6.1.6

Project configuration

... # somewhere in mkdocs.yml

repo_url: https://github.com/some-repo-that-is/private-or-does-not-exist

... # rest of file

System information

(should be irrelevant for this issue)

  • OS: macOS 10.13.6 / site built with docker python:3.7 image
  • Browser: Chrome 86
bug fix available

All 3 comments

Thanks for reporting! Definitely a regression that should be easy to fix:

https://github.com/squidfunk/mkdocs-material/blob/b72314d7da0e7c8bd2dda2f45c21d9cf55557706/src/assets/javascripts/patches/source/github/index.ts#L57-L58

The problem seems to be that the status code is > 200, but it's not considered an error. Same for GitHub orgs and GitLab.

Fixed in ca05a2d3. The request is now filtered for status === 200. If it doesn't succeed, the response is cached anyway for the duration of the session, as we don't want to flood GitHub's API. Same for GitLab.

Released as part of 6.1.7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yogeshbeniwal picture yogeshbeniwal  ·  4Comments

LinusGeffarth picture LinusGeffarth  ·  3Comments

yannduran picture yannduran  ·  4Comments

Timber232 picture Timber232  ·  3Comments

madrus picture madrus  ·  3Comments