rust-lang/rust · error · FailedCheck

No saved snapshot value

Error message

No saved snapshot value

What it means

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.

Source

Thrown at src/etc/htmldocck.py:356

    return match_count


def get_tree_count(tree, path):
    path = normalize_xpath(path)
    return len(tree.findall(path))


def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
    assert rust_test_path.endswith(".rs")
    snapshot_path = "{}.{}.{}".format(rust_test_path[:-3], snapshot_name, "html")
    try:
        with open(snapshot_path, "r") as snapshot_file:
            expected_str = snapshot_file.read().replace("{{channel}}", channel)
    except FileNotFoundError:
        if bless:
            expected_str = None
        else:
            raise FailedCheck("No saved snapshot value")  # noqa: B904 FIXME: py2

    if not normalize_to_text:
        actual_str = ET.tostring(actual_tree).decode("utf-8")
    else:
        actual_str = flatten(actual_tree)

    # Conditions:
    #  1. Is --bless
    #  2. Are actual and expected tree different
    #  3. Are actual and expected text different
    if (
        not expected_str
        or (
            not normalize_to_text
            and not compare_tree(make_xml(actual_str), make_xml(expected_str), stderr)
        )
        or (normalize_to_text and actual_str != expected_str)
    ):

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. Generate the golden by running htmldocck with --bless: `htmldocck.py <docdir> <template.rs> --bless`.
  2. Verify the generated snapshot file now exists next to the .rs test and commit it.
  3. Re-run without --bless to confirm the snapshot matches.

Example fix

// before
$ ./htmldocck.py build/doc tests/ui/mytest.rs
# FailedCheck: No saved snapshot value

// after
$ ./htmldocck.py build/doc tests/ui/mytest.rs --bless
$ git add tests/ui/mytest.my_snapshot.html
$ ./htmldocck.py build/doc tests/ui/mytest.rs
Defensive patterns

Strategy: validation

Validate before calling

import os

snapshot_path = f"{rust_test_path[:-3]}.{snapshot_name}.html"
if not os.path.exists(snapshot_path) and not bless:
    raise SystemExit(
        f"snapshot golden {snapshot_path!r} missing; run htmldocck with --bless to create it"
    )

Type guard

null

Try / catch

from srcetc_htmldocck import FailedCheck
try:
    check_snapshot(snapshot_name, subtree, normalize_to_text)
except FailedCheck as e:
    if "No saved snapshot value" in str(e):
        logging.error("create the golden with: htmldocck.py <doc> <rs> --bless")
    raise

Prevention

When it happens

Trigger: 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).

Common situations: Adding a new snapshot directive without first blessing it; rebasing after deleting old snapshots; running tests on a fresh checkout without generating goldens.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/1c8a60113a67a949. Report an issue: GitHub.