{"record":{"id":"7c4d5a4749f48123","repo":"vectordotdev/vector","slug":"paths-must-always-start-with-a-leading-forward-sla","errorCode":null,"errorMessage":"Paths must always start with a leading forward slash (`/`).","messagePattern":"Paths must always start with a leading forward slash \\(`/`\\)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/docs-renderer/src/renderer.rs","lineNumber":67,"sourceCode":"    /// The path follows the form of `/part1/part/.../partN`, where each slash-separated segment\n    /// represents a nested object within the overall object hierarchy. For example, a path of\n    /// `/root/nested/key2` would map to the value \"weee!\" if applied against the following JSON\n    /// object:\n    ///\n    ///   { \"root\": { \"nested\": { \"key2\": \"weee!\" } } }\n    ///\n    /// # Panics\n    ///\n    /// If the path does not start with a forward slash, this method will panic. Likewise, if the\n    /// path is _only_ a forward slash (aka there is no segment to describe the key within the\n    /// object to write the value to), this method will panic.\n    ///\n    /// If any nested object within the path does not yet exist, it will be created. If any segment,\n    /// other than the leaf segment, points to a value that is not an object/map, this method will\n    /// panic.\n    pub fn write<V: Into<Value>>(&mut self, path: &str, value: V) {\n        if !path.starts_with('/') {\n            panic!(\"Paths must always start with a leading forward slash (`/`).\");\n        }\n\n        self.with_mut_object(|map| {\n            // Split the path, and take the last element as the actual map key to write to.\n            let mut segments = path.split('/').collect::<VecDeque<_>>();\n            let key = segments.pop_back().expect(\"Path must end with a key.\");\n\n            // Iterate over the remaining elements, traversing into the root object one level at a\n            // time, based on using `token` as the map key. If there's no map at the given key,\n            // we'll create one. If there's something other than a map, we'll panic.\n            let mut destination = map;\n            while let Some(segment) = segments.pop_front() {\n                if destination.contains_key(segment) {\n                    match destination.get_mut(segment) {\n                        Some(Value::Object(next)) => {\n                            destination = next;\n                            continue;\n                        }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/docs-renderer/src/renderer.rs#L49-L85","documentation":"`Renderer::write` in lib/docs-renderer (used to assemble Vector's generated component documentation as JSON) treats `path` as a JSON-pointer-style path and requires it to start with `/`. A path without the leading slash has no defined root anchor for the segment walk, so the method panics immediately as a programmer-error assertion. The contract is spelled out in the `# Panics` section of the doc comment directly above the check.","triggerScenarios":"Calling `renderer.write(\"name\", value)` or `renderer.write(\"root/nested/key\", value)` instead of `renderer.write(\"/name\", value)`. Any `write` where the first character is not `/`, including empty-string paths.","commonSituations":"Contributing generated docs where a template or data-collection step formats paths without the leading slash; refactoring code that previously joined path segments without a root element; copy-pasting a path from JSON examples that omit the root slash.","solutions":["Prefix the path with a forward slash: `renderer.write(\"/name\", value)`.","Centralize path construction in a helper that always prepends `/` (e.g. `format!(\"/{key}\")`) so callers cannot pass bare keys.","If you meant to replace the entire document, use `replace_root`/`clear`-style APIs instead of a malformed root path."],"exampleFix":"// before\nrenderer.write(\"component_name\", Value::String(\"demo\".into()));\n\n// after\nrenderer.write(\"/component_name\", Value::String(\"demo\".into()));","handlingStrategy":"validation","validationCode":"assert!(path.starts_with('/'), \"Renderer paths must be rooted: {path}\");\nrenderer.write(path, value);","typeGuard":"fn is_rooted_path(p: &str) -> bool { p.starts_with('/') }","tryCatchPattern":null,"preventionTips":["Centralize path construction in one helper that always prepends '/'.","Never build Renderer paths by joining raw template strings; assert the format in debug builds.","Use the same normalization helper for write, delete and exists."],"tags":["rust","vector","docs-renderer","json-pointer","panic"],"backgroundTag":"invalid-json-pointer-path","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}