{"record":{"id":"9bea7162f4be68b1","repo":"rust-lang/rust","slug":"actual-snapshot-value-is-different-than-expected","errorCode":null,"errorMessage":"Actual snapshot value is different than expected","messagePattern":"Actual snapshot value is different than expected","errorType":"validation","errorClass":"FailedCheck","httpStatus":null,"severity":"error","filePath":"src/etc/htmldocck.py","lineNumber":385,"sourceCode":"    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    ):\n        if bless:\n            with open(snapshot_path, \"w\") as snapshot_file:\n                actual_str = actual_str.replace(channel, \"{{channel}}\")\n                snapshot_file.write(actual_str)\n        else:\n            print(\"--- expected ---\\n\")\n            print(expected_str)\n            print(\"\\n\\n--- actual ---\\n\")\n            print(actual_str)\n            print()\n            raise FailedCheck(\"Actual snapshot value is different than expected\")\n\n\n# Adapted from https://github.com/formencode/formencode/blob/3a1ba9de2fdd494dd945510a4568a3afeddb0b2e/formencode/doctest_xml_compare.py#L72-L120\ndef compare_tree(x1, x2, reporter=None):\n    if x1.tag != x2.tag:\n        if reporter:\n            reporter(\"Tags do not match: %s and %s\" % (x1.tag, x2.tag))\n        return False\n    for name, value in x1.attrib.items():\n        if x2.attrib.get(name) != value:\n            if reporter:\n                reporter(\n                    \"Attributes do not match: %s=%r, %s=%r\"\n                    % (name, value, name, x2.attrib.get(name))\n                )\n            return False\n    for name in x2.attrib:\n        if name not in x1.attrib:","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/htmldocck.py#L367-L403","documentation":"Raised as FailedCheck by check_snapshot() when the snapshot golden file exists and was loaded, but the actual generated output differs from the expected (and --bless was not passed, so it was not auto-updated). Before raising, the expected and actual values are printed to stderr to aid diagnosis. This is the canonical 'rustdoc output changed' failure.","triggerScenarios":"A snapshot directive's subtree (either as serialized XML or flattened text, depending on whether the XPath ended in /text()) does not equal the stored golden. Reached at htmldocck.py:385 in the non-bless branch.","commonSituations":"A rustdoc change altered rendering (whitespace, attribute order, class names, wrapper elements); a dependency or theme change affected output; the {{channel}} placeholder substitution diverged; the test crate's items changed.","solutions":["Read the printed --- expected --- / --- actual --- diff to understand the delta.","If the new output is correct, re-bless: `htmldocckck.py <docdir> <template.rs> --bless` and commit the updated golden.","If the change is unintended, fix the rustdoc regression that produced it, then re-run."],"exampleFix":"// before\n$ ./htmldocck.py build/doc tests/ui/mytest.rs\n# FailedCheck: Actual snapshot value is different than expected\n\n// after - review the diff, then bless if intentional\n$ ./htmldocck.py build/doc tests/ui/mytest.rs --bless\n$ git diff tests/ui/mytest.my_snapshot.html   # review\n$ git add tests/ui/mytest.my_snapshot.html","handlingStrategy":"validation","validationCode":"null","typeGuard":"null","tryCatchPattern":"from srcetc_htmldocck import FailedCheck\ntry:\n    check_snapshot(snapshot_name, subtree, normalize_to_text)\nexcept FailedCheck as e:\n    if \"Actual snapshot value is different\" in str(e):\n        logging.error(\"snapshot drifted; review diff and re-bless if intentional\")\n    raise","preventionTips":["Treat snapshot drift as a deliberate decision: review the diff, then bless or revert.","Run --bless in a separate commit from logic changes so golden updates are reviewable.","Pin rustdoc/rustc versions in CI to catch the exact commit that changed output."],"tags":["htmldocck","rustdoc","snapshot","golden-file","bless","regression"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}