{"record":{"id":"1c8a60113a67a949","repo":"rust-lang/rust","slug":"no-saved-snapshot-value","errorCode":null,"errorMessage":"No saved snapshot value","messagePattern":"No saved snapshot value","errorType":"validation","errorClass":"FailedCheck","httpStatus":null,"severity":"error","filePath":"src/etc/htmldocck.py","lineNumber":356,"sourceCode":"    return match_count\n\n\ndef get_tree_count(tree, path):\n    path = normalize_xpath(path)\n    return len(tree.findall(path))\n\n\ndef check_snapshot(snapshot_name, actual_tree, normalize_to_text):\n    assert rust_test_path.endswith(\".rs\")\n    snapshot_path = \"{}.{}.{}\".format(rust_test_path[:-3], snapshot_name, \"html\")\n    try:\n        with open(snapshot_path, \"r\") as snapshot_file:\n            expected_str = snapshot_file.read().replace(\"{{channel}}\", channel)\n    except FileNotFoundError:\n        if bless:\n            expected_str = None\n        else:\n            raise FailedCheck(\"No saved snapshot value\")  # noqa: B904 FIXME: py2\n\n    if not normalize_to_text:\n        actual_str = ET.tostring(actual_tree).decode(\"utf-8\")\n    else:\n        actual_str = flatten(actual_tree)\n\n    # Conditions:\n    #  1. Is --bless\n    #  2. Are actual and expected tree different\n    #  3. Are actual and expected text different\n    if (\n        not expected_str\n        or (\n            not normalize_to_text\n            and not compare_tree(make_xml(actual_str), make_xml(expected_str), stderr)\n        )\n        or (normalize_to_text and actual_str != expected_str)\n    ):","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/htmldocck.py#L338-L374","documentation":"Raised as FailedCheck by check_snapshot() when the snapshot file (named {rust_test_path}.{snapshot_name}.html) does not exist and the runner was not invoked with --bless. Snapshots are golden files; in normal (non-bless) mode a missing snapshot is a failure because there is no expected value to compare against.","triggerScenarios":"A `//@ snapshot: <name> <html-path> <xpath>` directive is evaluated, the snapshot golden file is absent (FileNotFoundError at line 352), and bless is False. Reached only on the missing-file branch (line 355-356).","commonSituations":"Adding a new snapshot directive without first blessing it; rebasing after deleting old snapshots; running tests on a fresh checkout without generating goldens.","solutions":["Generate the golden by running htmldocck with --bless: `htmldocck.py <docdir> <template.rs> --bless`.","Verify the generated snapshot file now exists next to the .rs test and commit it.","Re-run without --bless to confirm the snapshot matches."],"exampleFix":"// before\n$ ./htmldocck.py build/doc tests/ui/mytest.rs\n# FailedCheck: No saved snapshot value\n\n// after\n$ ./htmldocck.py build/doc tests/ui/mytest.rs --bless\n$ git add tests/ui/mytest.my_snapshot.html\n$ ./htmldocck.py build/doc tests/ui/mytest.rs","handlingStrategy":"validation","validationCode":"import os\n\nsnapshot_path = f\"{rust_test_path[:-3]}.{snapshot_name}.html\"\nif not os.path.exists(snapshot_path) and not bless:\n    raise SystemExit(\n        f\"snapshot golden {snapshot_path!r} missing; run htmldocck with --bless to create it\"\n    )","typeGuard":"null","tryCatchPattern":"from srcetc_htmldocck import FailedCheck\ntry:\n    check_snapshot(snapshot_name, subtree, normalize_to_text)\nexcept FailedCheck as e:\n    if \"No saved snapshot value\" in str(e):\n        logging.error(\"create the golden with: htmldocck.py <doc> <rs> --bless\")\n    raise","preventionTips":["Always bless new snapshot directives before committing.","Commit generated snapshot goldens alongside the .rs test.","In CI, detect missing goldens early and fail with a clear 'run --bless' message."],"tags":["htmldocck","rustdoc","snapshot","golden-file","bless"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}