{"record":{"id":"c0995592f6b05920","repo":"linera-io/linera-protocol","slug":"snap-file-path-is-missing-the-frontmatte","errorCode":null,"errorMessage":"SNAP file {path:?} is missing the `---` frontmatter delimiters","messagePattern":"SNAP file (.+?) is missing the `---` frontmatter delimiters","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"linera-client/src/client_context.rs","lineNumber":965,"sourceCode":"        .await?;\n\n        info!(\"{}\", \"Data blob verified successfully!\");\n        Ok(())\n    }\n}\n\n/// Reads an insta SNAP file containing a YAML-encoded `Formats` value and parses\n/// it. The caller BCS-serializes the result to obtain the application formats\n/// blob payload: BCS matches the documented intent (the blob is \"the BCS\n/// serialization of an application's `Formats`\") and the encoding the explorer\n/// decodes with.\n#[cfg(feature = \"fs\")]\nfn load_formats_from_snap(path: &std::path::Path) -> Result<linera_sdk::formats::Formats, Error> {\n    let content = fs::read_to_string(path).map_err(|e| {\n        std::io::Error::new(e.kind(), format!(\"failed to read SNAP file {path:?}: {e}\"))\n    })?;\n    let body = strip_snap_frontmatter(&content).ok_or_else(|| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            format!(\"SNAP file {path:?} is missing the `---` frontmatter delimiters\"),\n        )\n    })?;\n    let formats = serde_yaml_08::from_str(body).map_err(|e| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            format!(\"failed to parse SNAP body in {path:?} as Formats: {e}\"),\n        )\n    })?;\n    Ok(formats)\n}\n\n#[cfg(feature = \"fs\")]\nfn strip_snap_frontmatter(content: &str) -> Option<&str> {\n    let rest = content.strip_prefix(\"---\\n\")?;\n    let end = rest.find(\"\\n---\\n\")?;\n    Some(&rest[end + \"\\n---\\n\".len()..])","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-client/src/client_context.rs#L947-L983","documentation":"load_formats_from_snap expects the insta snapshot layout: a file starting with a `---` header line, a metadata block, a closing `---` line, then the YAML body with the Formats value (strip_snap_frontmatter at client_context.rs:980 requires a leading \"---\\n\" and a \"\\n---\\n\" terminator). If either delimiter is absent the function returns InvalidData with this message — the file was read fine but is not in snapshot format.","triggerScenarios":"Passing --formats a plain YAML file with no frontmatter, a file whose first line is not exactly `---`, a file using `...` or ``` fences instead of `---`, or one where the closing delimiter is missing or written as the very first/last line without trailing newlines. Any of these makes strip_snap_frontmatter return None.","commonSituations":"Hand-writing a formats file instead of using the insta-generated tests/snapshots/*.snap; exporting YAML from another tool and renaming it .snap; an editor or formatter stripping the leading `---` or collapsing blank lines; Windows line endings making the \"\\n---\\n\" literal match fail; trimming trailing newlines so the closing delimiter is not followed by a newline.","solutions":["Open the file and confirm line 1 is exactly `---` and that a later line is exactly `---` followed by a newline, with the Formats YAML after it — easiest check: compare against a known-good snapshot from tests/snapshots/ in the same repo.","Regenerate the file via the intended path (run the app's tests so insta writes the .snap, or copy a working .snap) rather than authoring it by hand.","If hand-authoring, switch line endings to LF and make sure no BOM precedes the first `---` and the closing `---` has content (the YAML body) after it."],"exampleFix":"# before: plain YAML, no frontmatter -> this error\nformat:\n  type: ... \n\n# after: insta snap layout (LF line endings, body after closing ---)\n---\nsource: tests/format.rs\nexpression: format\n---\ntype: ...\n","handlingStrategy":"validation","validationCode":"fn snap_has_frontmatter(content: &str) -> bool {\n    content.starts_with(\"---\\n\") && content[4..].contains(\"\\n---\\n\")\n}\n\n// std::fs::read_to_string(path).map(|c| snap_has_frontmatter(&c))? before publishing","typeGuard":"fn snap_has_frontmatter(content: &str) -> bool {\n    content.starts_with(\"---\\n\") && content[4..].contains(\"\\n---\\n\")\n}","tryCatchPattern":null,"preventionTips":["Only pass insta-generated snapshots to --formats; never hand-author a renamed YAML file.","Keep LF line endings and no BOM in .snap files (configure .gitattributes / editor settings).","Validate the delimiter layout in a pre-publish check so a mangled file fails fast with a clear message."],"tags":["rust","linera","snapshot","frontmatter","file-format"],"backgroundTag":"missing-frontmatter","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}