Setting `warning-policy` to "warn" still generates errors.
stevenj opened this issue · comments
When I run mdbook build with linkcheck enabled and warning-policy
set to "warn" it still errors and returns a 101 error code? How do I configure it to just warn?
$ cat book.toml; mdbook build; echo $?
[book]
authors = ["Steven Johnson (steven.johnson@iohk.io)"]
language = "en"
multilingual = false
src = "src"
title = "Project Catalyst Standards"
[build]
build-dir = "book" # This is where github wants it so we can publish as gh-pages.
[preprocessor.regex]
patterns = "./src/assets/patterns/patterns.json"
before = [ # Make sure regex pre-processing happens before any other pre-processing.
"kroki-preprocessor",
"admonish",
"open-on-gh"
]
[preprocessor.kroki-preprocessor]
[preprocessor.admonish]
command = "mdbook-admonish"
assets_version = "2.0.0" # do not edit: managed by `mdbook-admonish install`
on_failure = "bail"
before = [
"kroki-preprocessor" # Ensure we can put diagrams inside admonish blocks.
]
[preprocessor.open-on-gh]
command = "mdbook-open-on-gh"
renderer = ["html"]
[output.html]
additional-css = [
"./src/assets/css/mdbook-admonish.css",
"./src/assets/css/open-in.css"
]
# Required: Your repository URL used in the link.
git-repository-url = "https://github.com/input-output-hk/catalyst-standards"
# Your git branch. Defaults to `main`
git-branch = "main"
# The text to use in the footer.
# The link text is marked by `[]`
open-on-text = "Found a bug? [Edit this page on GitHub.]"
[output.html.search]
enable = true # enables the search feature
limit-results = 30 # maximum number of search results
teaser-word-count = 30 # number of words used for a search result teaser
use-boolean-and = true # multiple search terms must all match
boost-title = 2 # ranking boost factor for matches in headers
boost-hierarchy = 1 # ranking boost factor for matches in page names
boost-paragraph = 1 # ranking boost factor for matches in text
expand = true # partial words will match longer terms
heading-split-level = 3 # link results to heading levels
copy-js = true # include Javascript code for search
[output.linkcheck]
# Should we check links on the internet? Enabling this option adds a
# non-negligible performance impact
follow-web-links = true
# Are we allowed to link to files outside of the book's root directory? This
# may help prevent linking to sensitive files (e.g. "../../../../etc/shadow")
traverse-parent-directories = false
# If necessary, you can exclude one or more links from being checked with a
# list of regular expressions. The regex will be applied to the link href (i.e.
# the `./index.html` in `[some page](./index.html)`) so it can be used to
# ignore both web and filesystem links.
#
# Hint: you can use TOML's raw strings (single quote) to avoid needing to
# escape things twice.
# exclude = [ 'google\.com' ]
# The User-Agent to use when sending web requests
user-agent = "mdbook-linkcheck-0.7.7"
# The number of seconds a cached result is valid for (12 hrs by default)
cache-timeout = 43200
# How should warnings be treated?
#
# - "warn" will emit warning messages
# - "error" treats all warnings as errors, failing the linkcheck
# - "ignore" will ignore warnings, suppressing diagnostic messages and allowing
# the linkcheck to continuing
# We do NOT allow broken links in CI, but only warn in development.
# DO NOT EDIT THIS SETTING OR YOu WILL BREAK CI.
warning-policy = "warn"
# Extra HTTP headers that must be send to certain web sites
# in order to link check to succeed.
#
# This is a dictionary (map), with keys being regexes
# matching a set of web sites, and values being an array of
# the headers.
[output.linkcheck.http-headers]
# Any hyperlink that contains this regexp will be sent
# the "Accept: text/html" header
'crates\.io' = ["Accept: text/html"]
# mdbook-linkcheck will interpolate environment variables into your header via
# $IDENT.
#
# If this is not what you want you must escape the `$` symbol, like `\$TOKEN`.
# `\` itself can also be escaped via `\\`.
#
# Note: If interpolation fails, the header will be skipped and the failure will
# be logged. This can be useful if a particular header isn't always necessary,
# but may be helpful (e.g. when working with rate limiting).
#'website\.com' = ["Authorization: Basic $TOKEN"]2023-01-13 14:34:24 [INFO] (mdbook::book): Book building has started
2023-01-13 14:34:24 [INFO] (mdbook::book): Running the html backend
2023-01-13 14:34:24 [INFO] (mdbook::book): Running the linkcheck backend
2023-01-13 14:34:24 [INFO] (mdbook::renderer): Invoking the "linkcheck" renderer
error: File not found: ./doesnt_exist.html
┌─ chapter_1.md:3:1
│
3 │ [broken link](./doesnt_exist.html)
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File not found: ./doesnt_exist.html
Error: One or more incorrect links
2023-01-13 14:34:24 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2023-01-13 14:34:24 [ERROR] (mdbook::utils): Error: Rendering failed
2023-01-13 14:34:24 [ERROR] (mdbook::utils): Caused By: The "linkcheck" renderer failed
101
I know its picking up the warning-policy
option because if I make it an invalid value mdbook-linkcheck complains.
+1 I have the same issue. It's quite bad in the scenario that a Github CI workflow deployment depends on
the right behavior of this option.
After a quick look at the code it looks like the add_invalid_link_diagnostics
function does not respect the warning_policy
, it always generates an error:
mdbook-linkcheck/src/validate.rs
Line 285 in dc22a02
Potential solution is to follow the pattern from add_incomplete_link_diagnostics
instead:
mdbook-linkcheck/src/validate.rs
Line 270 in dc22a02