rust-lang/mdBook · error
failed to get `{key}`: {e}
Error message
failed to get `{key}`: {e} What it means
preprocessor_should_run() reads the `preprocessor.<name>.renderers` list via Config::get(); if that read errors (e.g. the value has the wrong type and cannot deserialize to Vec<String>, or get() was given an invalid key) the error is wrapped with this context.
Source
Thrown at crates/mdbook-driver/src/mdbook.rs:567
fn preprocessor_should_run(
preprocessor: &dyn Preprocessor,
renderer: &dyn Renderer,
cfg: &Config,
) -> Result<bool> {
// default preprocessors should be run by default (if supported)
if cfg.build.use_default_preprocessors && is_default_preprocessor(preprocessor) {
return preprocessor.supports_renderer(renderer.name());
}
let key = format!("preprocessor.{}.renderers", preprocessor.name());
let renderer_name = renderer.name();
match cfg.get::<Vec<String>>(&key) {
Ok(Some(explicit_renderers)) => {
Ok(explicit_renderers.iter().any(|name| name == renderer_name))
}
Ok(None) => preprocessor.supports_renderer(renderer_name),
Err(e) => bail!("failed to get `{key}`: {e}"),
}
}
View on GitHub (pinned to dc21064fc2)
Solutions
- Change renderers to a TOML array: renderers = ["html"]
- Remove the renderers key to fall back to the preprocessor's supports_renderer() method
- Validate book.toml with `mdbook build` output or TOML linting
Example fix
// before (book.toml) [preprocessor.links] renderers = "html" // after [preprocessor.links] renderers = ["html"]
Defensive patterns
Strategy: validation
Validate before calling
// validate book.toml before build
let raw = toml::from_str::<toml::Value>(&std::fs::read_to_string("book.toml")?)?;
if let Some(r) = raw.get("preprocessor").and_then(|p| p.get("links")).and_then(|l| l.get("renderers")) {
assert!(r.is_array(), "preprocessor.links.renderers must be a TOML array");
} Try / catch
match preprocessor_should_run(&pp, renderer, &cfg) {
Ok(run) => /* ... */,
Err(e) if e.to_string().contains("failed to get") => {
eprintln!("check preprocessor.<name>.renderers is an array: {e}");
}
Err(e) => return Err(e),
} Prevention
- Always write renderers as a TOML array: renderers = ["html"]
- Never quote booleans or arrays in book.toml
- Run mdbook build once after config edits to validate types
When it happens
Trigger: book.toml containing `renderers = "html"` (a string instead of an array) or other non-list value under preprocessor.<name>.renderers; nested get() failures from the config layer.
Common situations: Hand-edited book.toml with a malformed renderers entry; copying config snippets where renderers is a single string.
Related errors
- expected bool for `{optional_key}`: {e}
- unable to get `{name}`, only `output` and `preprocessor` tab
- invalid key `{index}`
- invalid key `{name}`
- redirect entry for `{original}` only has source paths with `
AI-assisted analysis of rust-lang/mdBook@dc21064fc2 (2026-09-01).
Data as JSON: /api/errors/6e812fc118ea835f.
Report an issue: GitHub.