{"record":{"id":"5e0c7471bb51bb0b","repo":"FuelLabs/fuels-rs","slug":"couldn-t-find-a-matching-end-anchor-for-start","errorCode":null,"errorMessage":"Couldn't find a matching end anchor for {start:?}","messagePattern":"Couldn't find a matching end anchor for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"scripts/check-docs/src/lib.rs","lineNumber":119,"sourceCode":"    apply_regex(\n        Regex::new(r\"^(\\S+):(\\d+):\\s*\\{\\{\\s*#include\\s*(\\S+?)\\s*(?::\\s*(\\S+)\\s*)?\\}\\}\")\n            .expect(\"could not construct regex\"),\n    )\n}\n\npub fn filter_valid_anchors(starts: Vec<Anchor>, ends: Vec<Anchor>) -> (Vec<Anchor>, Vec<Error>) {\n    let find_anchor_end_by_name = |anchor_name: &str, file: &Path| {\n        ends.iter()\n            .filter(|el| el.name == *anchor_name && el.file == file)\n            .collect::<Vec<_>>()\n    };\n\n    let (pairs, errors):(Vec<_>, Vec<_>) = starts.into_iter().map(|start| {\n        let matches_by_name = find_anchor_end_by_name(&start.name, &start.file);\n\n        let (begin, end) = match matches_by_name.as_slice() {\n            [single_match] => Ok((start, (*single_match).clone())),\n            [] => Err(anyhow!(\"Couldn't find a matching end anchor for {start:?}\")),\n            multiple_ends => Err(anyhow!(\"Found too many matching anchor ends for anchor: {start:?}. The matching ends are: {multiple_ends:?}\")),\n        }?;\n\n        match check_validity_of_anchor_pair(&begin, &end) {\n            None => Ok((begin, end)),\n            Some(err) => {\n                let err_msg = err.to_string();\n                Err(anyhow!(\"{err_msg}\"))\n            }\n        }\n    }).partition_result();\n\n    let additional_errors = filter_unused_ends(&ends, &pairs)\n        .into_iter()\n        .map(|unused_end| anyhow!(\"Missing anchor start for {unused_end:?}\"))\n        .collect::<Vec<_>>();\n\n    let start_only = pairs.into_iter().map(|(begin, _)| begin).collect();","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/FuelLabs/fuels-rs/blob/d9a250a51818dda64bfeb5ef7cc19cf27bdcd623/scripts/check-docs/src/lib.rs#L101-L137","documentation":"Doc-checking error (scripts/check-docs): a start marker ANCHOR: <name> was found but no matching ANCHOR_END: <name> exists in the same file. Anchor pairing requires exactly one end marker with the same name in the same file; zero matches produce this error.","triggerScenarios":"A source file contains ANCHOR: my_name but the corresponding ANCHOR_END: my_name is missing, misspelled, in a different file, or the start name was edited without updating the end.","commonSituations":"Copy-pasting an ANCHOR block and altering only the start name; deleting the end marker while trimming an example; renaming an anchor on one line only.","solutions":["In the file reported by the error, locate the ANCHOR: <name> marker.","Add or fix the matching ANCHOR_END: <name> after the snippet's last line, with the identical name.","Ensure start and end are in the same file; move markers if the snippet spans files.","Re-run check-docs to confirm pairing."],"exampleFix":"// before\n// ANCHOR: transfer_funds\npub async fn transfer() { /* ... */ }\n// ANCHOR_END: transfer\n// after\n// ANCHOR: transfer_funds\npub async fn transfer() { /* ... */ }\n// ANCHOR_END: transfer_funds","handlingStrategy":"validation","validationCode":"let src = fs::read_to_string(file)?;\nlet starts: Vec<&str> = src.lines().filter_map(|l| l.strip_prefix(\"// ANCHOR:\")).map(str::trim).collect();\nlet ends: Vec<&str> = src.lines().filter_map(|l| l.strip_prefix(\"// ANCHOR_END:\")).map(str::trim).collect();\nfor s in &starts {\n    assert!(ends.contains(s), \"missing ANCHOR_END: {s} in {file:?}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add ANCHOR_END in the same edit that adds ANCHOR.","Use editor snippets/multi-cursor to emit both markers together.","Run check-docs before committing example changes."],"tags":["docs","check-docs","anchors","markdown"],"backgroundTag":null,"analyzedSha":"d9a250a51818dda64bfeb5ef7cc19cf27bdcd623","analyzedAt":"2026-08-16T09:49:30.618Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}