{"record":{"id":"653b54f23dea3edd","repo":"rust-lang/rust","slug":"target-block-for-the-title-is-not-found","errorCode":null,"errorMessage":"target block for the title is not found","messagePattern":"target block for the title is not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/tools/rust-analyzer/xtask/src/publish/notes.rs","lineNumber":189,"sourceCode":"                    return Ok(());\n                } else {\n                    self.write_line(&line, level);\n                }\n            }\n            bail!(\"listing block is not terminated\")\n        }\n        bail!(\"not a listing block\")\n    }\n\n    fn process_block_with_title(&mut self, level: usize) -> anyhow::Result<()> {\n        if let Some(Ok(line)) = self.iter.next() {\n            let title =\n                line.strip_prefix('.').ok_or_else(|| anyhow!(\"extraction of the title failed\"))?;\n\n            let line = self\n                .iter\n                .peek()\n                .ok_or_else(|| anyhow!(\"target block for the title is not found\"))?;\n            let line = line.as_deref().map_err(|e| anyhow!(\"{e}\"))?;\n            if line.starts_with(IMAGE_BLOCK_PREFIX) {\n                return self.process_image_block(Some(title), level);\n            } else if line.starts_with(VIDEO_BLOCK_PREFIX) {\n                return self.process_video_block(Some(title), level);\n            } else {\n                bail!(\"title for that block type is not supported\");\n            }\n        }\n        bail!(\"not a title\")\n    }\n\n    fn process_image_block(&mut self, caption: Option<&str>, level: usize) -> anyhow::Result<()> {\n        if let Some(Ok(line)) = self.iter.next()\n            && let Some((url, attrs)) = parse_media_block(&line, IMAGE_BLOCK_PREFIX)\n        {\n            let alt =\n                if let Some(stripped) = attrs.strip_prefix('\"').and_then(|s| s.strip_suffix('\"')) {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/rust-analyzer/xtask/src/publish/notes.rs#L171-L207","documentation":"Thrown by rust-analyzer's AsciiDoc-to-Markdown converter after it consumes a '.Caption' line in process_block_with_title. The converter peeks at the next line to find the target block (image:: or video::) that the caption applies to. If self.iter.peek() returns None — meaning the input ended right after the title line — there is no block to attach the caption to and this error fires.","triggerScenarios":"Feeding an AsciiDoc file whose last non-blank line is a block title (e.g., '.My Screenshot') with no subsequent image::[] or video::[] block. Also triggered if the title line is followed only by blank lines or EOF.","commonSituations":"Release notes draft left incomplete with a dangling caption; copy-paste of an AsciiDoc snippet that included a caption but not its media block; trailing '.' line left by an editor auto-format.","solutions":["Add the missing image::filename[alt] or video::filename[attrs] block immediately after the '.Caption' line.","Remove the orphaned '.Caption' line if the block was intentionally deleted.","Run the converter on the file locally (cargo test -p xtask or the test_asciidoc_to_markdown_conversion test) to verify the fix before committing."],"exampleFix":"// before (dangling title in .adoc):\n.Screenshot of the new UI\n// (EOF — no block follows)\n// after:\n.Screenshot of the new UI\nimage::screenshot.png[Screenshot of the new UI]","handlingStrategy":"validation","validationCode":"// Pre-validate that every block title (.Caption) has a following media block.\nfn check_titles_have_blocks(input: &str) -> Result<(), String> {\n    let lines: Vec<&str> = input.lines().collect();\n    for (i, line) in lines.iter().enumerate() {\n        if line.strip_prefix('.').is_some() && !line.starts_with(\"..\") {\n            match lines.get(i + 1) {\n                Some(next) if next.starts_with(\"image::\") || next.starts_with(\"video::\") => {}\n                _ => return Err(format!(\"block title '{}' at line {} has no target block\", line, i + 1)),\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// Rust: convert_asciidoc_to_markdown returns anyhow::Result<String>\nlet markdown = convert_asciidoc_to_markdown(std::io::Cursor::new(&input))\n    .map_err(|e| format!(\"release notes conversion error: {e:#}\"))?;","preventionTips":["Never leave a .Caption line as the last content line in an AsciiDoc file.","When editing release notes, verify each caption has its corresponding image/video block.","Use the existing test fixture (test_data/input.adoc) as a syntax reference."],"tags":["rust-analyzer","asciidoc","converter","release-notes","xtask"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}