squidfunk / mkdocs-material

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

Locally cached external content fails in strict mode #7727

Closed pana-exfo closed 1 week ago

pana-exfo commented 1 week ago

Context

Build server is offline and external content is cached locally

Bug description

Current behavior Privacy plugin is using files from local cache and gives warnings. When running in strict mode, these warnings cause build to fail.

Expected behavior Privacy plugin is using files from local cache and prints warning if files are missing from local cache.

Related links

Reproduction

9.5.44-cached-privacy-fail-in-strict-mode.zip

Steps to reproduce

  1. Comment assets_fetch (assets_fetch: false) in config
  2. Run build with mkdocs build to download content to cache
  3. Run build with mkdocs build --strict

Browser

No response

Before submitting

squidfunk commented 1 week ago

Thanks for reporting. This is intended behavior. Setting assets_fetch to false sets the privacy plugin into "reporting" mode, which ensures that you are not using external assets. The use case is that you self-host by yourself, but want a safety net so that you do not use external assets accidentally. This is also why this has to be a warning:

Use this setting to control whether the plugin should downloads or only report external assets when they're encountered. If you already self-host all external assets, this setting can be used as a safety net to detect links to external assets placed by the author in pages.

However, you can easily achieve what you want by setting log_level to error:

plugins:
  - privacy:
      cache_dir: dir/
      assets_fetch: false
      log_level: error

Result:

$ mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: .../site
INFO    -  Documentation built in 0.15 seconds

It's always a good idea to check the plugin settings, as our plugins have plenty.