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
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/14611-sentinel-the-log-says-snapshot-refs-left → main 3 commits fork 1 thread · 1 unresolved
2 files
changed +20
−2
src/snapshot/snapshot.ts +4 −1
| @@ -598,7 +598,10 @@ export async function takeSnapshot( | ||
| 598 | 598 | } |
| 599 | 599 | if (made.brokenRefs.length > 0) { |
| 600 | 600 | 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", { | |
| 602 | 605 | repo: full, |
| 603 | 606 | refs: made.brokenRefs.length, |
| 604 | 607 | first: made.brokenRefs[0] ?? "", |
test/snapshot-repositories.test.ts +16 −1
| @@ -14,7 +14,8 @@ | ||
| 14 | 14 | * refuses a manifest in which a repository has neither a bundle nor a reason; and the |
| 15 | 15 | * destination is sealed by one setting, off by default, with the status saying which it is. |
| 16 | 16 | */ |
| 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"; | |
| 18 | 19 | import { |
| 19 | 20 | existsSync, |
| 20 | 21 | mkdirSync, |
| @@ -237,8 +238,19 @@ describe("a repository with refs whose commits are missing", () => { | ||
| 237 | 238 | version: "t", |
| 238 | 239 | nightly: false, |
| 239 | 240 | }); |
| 241 | const err = spyOn(console, "error").mockImplementation(() => {}); | |
| 242 | const warn = spyOn(console, "warn").mockImplementation(() => {}); | |
| 243 | const level = logLevel(); | |
| 244 | setLogLevel("warn"); | |
| 240 | 245 | try { |
| 241 | 246 | 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 | |
| 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); | |
| 242 | 254 | const kept = lastSnapshotOutcome(app.config.dataDir); |
| 243 | 255 | expect(kept?.brokenRefs).toEqual([ |
| 244 | 256 | { repo: "alice/notes", refs: ["refs/heads/lost", "refs/heads/torn"] }, |
| @@ -262,6 +274,9 @@ describe("a repository with refs whose commits are missing", () => { | ||
| 262 | 274 | "2 branches of alice/notes cannot be backed up: their commits are missing (lost, torn)", |
| 263 | 275 | ); |
| 264 | 276 | } finally { |
| 277 | err.mockRestore(); | |
| 278 | warn.mockRestore(); | |
| 279 | setLogLevel(level); | |
| 265 | 280 | await svc.stop(); |
| 266 | 281 | } |
| 267 | 282 | // More than five are counted, not all listed; a later snapshot with none clears the line. |
new above
offline
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.