Public: anyone can read this; the crew can change it.

Sentinel: The log says "snapshot: refs left out of the snapshot: their commits are missing repo=scout/forge refs=…" 3 times #14636

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/14611-sentinel-the-log-says-snapshot-refs-left → main 3 commits fork 1 thread · 1 unresolved

  • Merged. mason/14611-sentinel-the-log-says-snapshot-refs-left was merged into main as 277d7bd.

Review

Sign in to review this change.
2 files changed +20 −2
src/snapshot/snapshot.ts +4 −1
@@ -598,7 +598,10 @@ export async function takeSnapshot(
598598 }
599599 if (made.brokenRefs.length > 0) {
600600 brokenRefs.push({ repo: full, refs: [...made.brokenRefs] });
601 log.error("refs left out of the snapshot: their commits are missing", {
601 // The snapshot landed and the backups card names these refs until they are cleared: a
602 // warning each night, not an error each night for a repository the admin already has a card
603 // for.
604 log.warn("refs left out of the snapshot: their commits are missing", {
602605 repo: full,
603606 refs: made.brokenRefs.length,
604607 first: made.brokenRefs[0] ?? "",
test/snapshot-repositories.test.ts +16 −1
@@ -14,7 +14,8 @@
1414 * refuses a manifest in which a repository has neither a bundle nor a reason; and the
1515 * destination is sealed by one setting, off by default, with the status saying which it is.
1616 */
17 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
17 import { afterAll, beforeAll, describe, expect, spyOn, test } from "bun:test";
18 import { logLevel, setLogLevel } from "../src/kernel/log.ts";
1819 import {
1920 existsSync,
2021 mkdirSync,
@@ -237,8 +238,19 @@ describe("a repository with refs whose commits are missing", () => {
237238 version: "t",
238239 nightly: false,
239240 });
241 const err = spyOn(console, "error").mockImplementation(() => {});
242 const warn = spyOn(console, "warn").mockImplementation(() => {});
243 const level = logLevel();
244 setLogLevel("warn");
240245 try {
241246 await svc.now();
247 // The card carries it: the log says it once a night as a warning, never as an error.
248 const loud = (spy: typeof err) =>
249 spy.mock.calls
outdated

Restore the spies and the level in a finally. As written, a failing expect above leaves console.error and console.warn mocked, and the log level at warn, for the rest of the file.

250 .map(String)
251 .filter((l) => l.includes("refs left out of the snapshot"));
252 expect(loud(err)).toEqual([]);
253 expect(loud(warn).length).toBe(1);
242254 const kept = lastSnapshotOutcome(app.config.dataDir);
243255 expect(kept?.brokenRefs).toEqual([
244256 { repo: "alice/notes", refs: ["refs/heads/lost", "refs/heads/torn"] },
@@ -262,6 +274,9 @@ describe("a repository with refs whose commits are missing", () => {
262274 "2 branches of alice/notes cannot be backed up: their commits are missing (lost, torn)",
263275 );
264276 } finally {
277 err.mockRestore();
278 warn.mockRestore();
279 setLogLevel(level);
265280 await svc.stop();
266281 }
267282 // More than five are counted, not all listed; a later snapshot with none clears the line.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs