fix: attribute Sentry errors to the loaded source release (#13719)

Attribute optional server and browser Sentry events to their source build.
Use validated build commits for Docker and source/npm artifacts, preserve
explicit server release overrides, and keep cached browser bundles tied
to the commit they loaded.

Verify 127 focused tests, server/UI typechecks, Docker and source build
stamps, all 53 CI checks, and Greptile 5/5 with no unresolved comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip authored and GitHub committed 2026-09-20 08:08:33 -07:00
1 parent 2a99de80ec
commit 600e552d7b
14 files changed
+268 -10

No files matched your search

+9 -2
View File
@@ -7,6 +7,7 @@ const FULL_SHA_RE = /^[0-9a-f]{40}$/i;
const DEFAULT_BUILD_COMMIT_PATH = fileURLToPath(
new URL("../../.paperclip-build-commit", import.meta.url),
);
const DEFAULT_BUILD_INFO_PATH = fileURLToPath(new URL("./build-info.json", import.meta.url));
export function parseBuildCommit(value: string | null | undefined): string | null {
const commit = value?.trim() ?? "";
@@ -17,6 +18,7 @@ export function readBuildCommit(
opts: {
environmentCommit?: string | null;
buildCommitPath?: string;
buildInfoPath?: string;
readTextFile?: ReadTextFile;
} = {},
): string | null {
@@ -27,9 +29,14 @@ export function readBuildCommit(
);
if (environmentCommit) return environmentCommit;
const readTextFile = opts.readTextFile ?? ((path: string) => readFileSync(path, "utf8"));
try {
const readTextFile = opts.readTextFile ?? ((path: string) => readFileSync(path, "utf8"));
return parseBuildCommit(readTextFile(opts.buildCommitPath ?? DEFAULT_BUILD_COMMIT_PATH));
const markerCommit = parseBuildCommit(readTextFile(opts.buildCommitPath ?? DEFAULT_BUILD_COMMIT_PATH));
if (markerCommit) return markerCommit;
} catch { /* The deployment marker is absent in npm packages. */ }
try {
const stamp = JSON.parse(readTextFile(opts.buildInfoPath ?? DEFAULT_BUILD_INFO_PATH));
return typeof stamp?.commit === "string" ? parseBuildCommit(stamp.commit) : null;
} catch {
return null;
}