squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
20.63k stars 3.51k forks source link

removing simple/outlook crashed the entire website upon rebuild #7415

Closed ryzenpay closed 2 months ago

ryzenpay commented 2 months ago

Context

I had mkdocs serving on a persistant storage on an RKE cluster. i made some changes to a script that was running within and ended up deleting the persistant volume. this made the docker image pull from git again, and continued to crash the startup of the wiki because i was using the icon "simple/outlook" which can now no longer be found on the github either. I was making this to make error handling for a situation where the icon does not exist and it replaces it with a default rather than fully stop the mkdocs from starting up.

Bug description

I was making this to make error handling for a situation where the icon does not exist and it replaces it with a default rather than fully stop the mkdocs from starting up. Adding to this, the error message it does provide only links to the "index" page where the sub pages are first referenced, which initially made it difficult to find.

dump of the error log:

ERROR   -  Error building page 'email.md': .icons/simple/microsoftoutlook.svg
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs/__main__.py", line 268, in serve_command
    serve.serve(**kwargs)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 85, in serve
    builder(config)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, serve_url=None if is_clean else serve_url, dirty=is_dirty)
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 337, in build
    _build_page(
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 223, in _build_page
    output = template.render(context)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/docs/overrides/main.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/local/lib/python3.11/site-packages/material/templates/base.html", line 154, in top-level template code
    {% block site_nav %}
^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/material/templates/base.html", line 162, in block 'site_nav'
    {% include "partials/nav.html" %}
^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/material/templates/partials/nav.html", line 27, in top-level template code
    {{ item.render(nav_item, path, 1) }}
^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/material/templates/partials/nav-item.html", line 115, in template
    {{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }}
^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/material/templates/partials/nav-item.html", line 148, in template
    {{ render_content(nav_item) }}
^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/material/templates/partials/nav-item.html", line 15, in template
    {% include ".icons/" ~ nav_item.meta.icon ~ ".svg" %}
^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/loaders.py", line 207, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: .icons/simple/microsoftoutlook.svg

Related links

Reproduction

As the mkdocs contains sensitive information i cannot provide a zip, but attempt to use the icon "simple/outlook" and you will receive the same error

Steps to reproduce

As the mkdocs contains sensitive information i cannot provide a zip, but attempt to use the icon "simple/outlook" and you will receive the same error

Browser

No response

Before submitting

squidfunk commented 2 months ago

Thanks for reporting. Unfortunately, this is an upstream issue that was caused by a legal dispute. Thus, it's probably best to complain at Microsoft, as they do not want their icons to be part of the Simple Icons set.

alexvoss commented 2 months ago

Can't help but add my 2p here as well, regarding the proposed solution. IMHO it is better to let a build fail than to have output that is not as desired. Some action will need to be taken and while it may be annoying to be forced into it, better get it over with than incur the debt. As I said, just my 2p.

This is wider issue, btw., that some companies do not allow use of their icons and ask Simple Icons to remove them. Oracle is another example and it seems Adobe belong in this group, too. I know what I would map all of the removed icons to...

squidfunk commented 2 months ago

Also note that the icon integration is implemented with the limited capabilities we have in Jinja – we can only include the icon or fail if it doesn't exist, and Jinja does not allow to provide a detailed error message. @alexvoss we should look into moving the icons out of core in the future, so that the icon version can be updated/pinned separately. This should make builds much more stable. Same goes for other third-party bundled assets.