{"record":{"id":"4d6d607a1d42a05b","repo":"rust-lang/mdBook","slug":"unable-to-get-name-only-output-and-preproc","errorCode":null,"errorMessage":"unable to get `{name}`, only `output` and `preprocessor` table entries are allowed","messagePattern":"unable to get `(.+?)`, only `output` and `preprocessor` table entries are allowed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mdbook-core/src/config.rs","lineNumber":195,"sourceCode":"\n    /// Get a value from the configuration.\n    ///\n    /// This fetches a value from the book configuration. The key can have\n    /// dotted indices to access nested items (e.g. `output.html.playground`\n    /// will fetch the \"playground\" out of the html output table).\n    ///\n    /// This can only access the `output` and `preprocessor` tables.\n    ///\n    /// Returns `Ok(None)` if the field is not set.\n    ///\n    /// Returns `Err` if it fails to deserialize.\n    pub fn get<'de, T: Deserialize<'de>>(&self, name: &str) -> Result<Option<T>> {\n        let (key, table) = if let Some(key) = name.strip_prefix(\"output.\") {\n            (key, &self.output)\n        } else if let Some(key) = name.strip_prefix(\"preprocessor.\") {\n            (key, &self.preprocessor)\n        } else {\n            bail!(\n                \"unable to get `{name}`, only `output` and `preprocessor` table entries are allowed\"\n            );\n        };\n        table\n            .read(key)\n            .map(|value| {\n                value\n                    .clone()\n                    .try_into()\n                    .with_context(|| format!(\"Failed to deserialize `{name}`\"))\n            })\n            .transpose()\n    }\n\n    /// Returns whether the config contains the given dotted key name.\n    ///\n    /// The key can have dotted indices to access nested items (e.g.\n    /// `preprocessor.foo.bar` will check if that key is set in the config).","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/rust-lang/mdBook/blob/dc21064fc21d955a0e1f67e65e336883c3e5260b/crates/mdbook-core/src/config.rs#L177-L213","documentation":"Config::get() only supports reading namespaced entries from the `output.*` or `preprocessor.*` tables of book.toml. Any other key (e.g. `build.` or `rust.` settings) is rejected with this error. It exists to keep the generic get() API scoped to plugin/output configuration surfaces.","triggerScenarios":"Calling config.get::<T>(\"build.dir\") or any key that does not start with \"output.\" or \"preprocessor.\" (note: the exact prefix \"output.\" / \"preprocessor.\", so \"output\" or \"preprocessors\" also fail).","commonSituations":"Plugin or custom renderer code trying to read general config like [build] or [book] via get(); typos in the prefix such as \"outputs.html\" or a missing dot.","solutions":["Use Config::book, Config::build, Config::rust, or Config::get_table for non-output/preprocessor settings","Prefix the key with \"output.\" or \"preprocessor.\" if that is what you intended","Read the raw table via deserialize the whole config instead of get() for other sections"],"exampleFix":"// before\nlet dir: Option<String> = config.get(\"build.build-dir\")?;\n// after\nlet dir = config.build.build_dir().to_string_lossy().to_string();","handlingStrategy":"validation","validationCode":"fn gettable(name: &str) -> bool {\n    name.starts_with(\"output.\") || name.starts_with(\"preprocessor.\")\n}","typeGuard":"fn is_namespaced_key(name: &str) -> bool {\n    name.starts_with(\"output.\") || name.starts_with(\"preprocessor.\")\n}","tryCatchPattern":"match config.get::<Value>(key) {\n    Ok(v) => /* use v */,\n    Err(e) if e.to_string().contains(\"only `output` and `preprocessor`\") =>\n        /* read from config.book / config.build instead */,\n    Err(e) => return Err(e),\n}","preventionTips":["Only call Config::get() for output.* and preprocessor.* keys","Use the typed accessors (config.book, config.build, config.rust) for other sections","Include the dot in the prefix — bare \"output\" is invalid"],"tags":["config","api-misuse"],"backgroundTag":"invalid-config-key","analyzedSha":"dc21064fc21d955a0e1f67e65e336883c3e5260b","analyzedAt":"2026-09-01T10:15:12.134Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}