/** * WHAT A SHIPPING ARCHIVE DOES ABOUT SYMBOLS — AND WHY IT UPLOADS NOTHING. * * A SWIFT ARCHIVE HAS NO SOURCE MAP — it has a dSYM and nothing else — and * Bugsink cannot symbolicate one. Its chunk-upload endpoint advertises `debug_files` and * `files/difs/assemble/` stores a dSYM with its debug-id, but nothing reads one * back: a regular event goes through `events/utils.py::apply_sourcemaps`, which * keeps only images whose `type == "sourcemap"` and drops the `macho` images an * Apple SDK sends, and the only other reader is minidump-only behind a flag * Bugsink's own changelog calls development-only. Native dSYM symbolication is * bugsink/bugsink#20, open since January 2025. The Mac reached this first and * ships with `enableCrashHandler = false` for exactly this reason * (`apps/cotton/App/CottonDB/Reporting+Sentry.swift`). * * So there is no sentry-cli in the phone's archive and no token for it to need. * What the lane owes a future crash report is the dSYM ITSELF, kept where * `atos` and Xcode can reach it — because `discard_archive!` deletes the * archive minutes later and every workflow ends with `rm -rf build`. * * Four things are pinned here, and every one of them is a QUIET failure: * 1. the shipping lane preserves its dSYMs, and refuses an archive with none; * 2. it does so BEFORE `discard_archive!` — the ordering bug that would lose * them with a green build and no message; * 3. they are kept OUTSIDE the repo tree the workflows delete; * 4. no Sentry SaaS coordinate, and no `SENTRY_*` upload switch, has crept * back into the Fastfile or any workflow. */import { readFileSync } from"node:fs";import { join, resolve } from"node:path";import { describe, expect, it } from"vitest";const REPO_ROOT = resolve(__dirname, "../..");/** * A LOUD read. A regex over an empty string passes, which is how a moved file * turns a guard green — the failure this repo has written a paragraph about. */const read = (...parts: string[]) => {const path = join(REPO_ROOT, ...parts);const text = readFileSync(path, "utf8"); expect(text.length, `${path} is empty — did the file move?`).toBeGreaterThan(0);return text;};const fastfile = () => read("fastlane", "Fastfile");/** * The Fastfile with every comment line dropped — CODE only. * * Half this file's assertions are about what the lane no longer DOES, and the * file explains each of those deletions in a comment naming the thing deleted. * A test over the raw text would forbid the file from explaining itself, which * is how a repo loses the reason for a decision one PR at a time. */const fastfileCode = () => fastfile() .split("\n") .filter((line) => !line.trimStart().startsWith("#")) .join("\n");/** * Lanes that produce a build a PERSON installs. `ios_dryrun!` is absent on * purpose: it archives, uploads nothing anywhere and reaches nobody, so it has * no symbols to keep. */const SHIPPING_LANES = ["def ios_beta!"];/** Every workflow, and whether the build it runs reaches a person. */const WORKFLOWS: Array<[string, boolean]> = [ ["release.yml", true], ["build-main.yml", true], ["build-prod-dryrun.yml", false],];describe("a shipping archive keeps its dSYMs", () => {for (const lane of SHIPPING_LANES) { it(`${lane} preserves them, and does it before the archive is discarded`, () => {// CODE only: the comment above the call names `discard_archive!` to// explain the order, which would read as the call itself.const text = fastfileCode();const start = text.indexOf(lane); expect(start, `${lane} is not in the Fastfile`).toBeGreaterThan(-1);const body = text.slice(start, text.indexOf("\nend\n", start));const preserved = body.indexOf("preserve_dsyms!"); expect(preserved, `${lane} does not preserve its dSYMs`).toBeGreaterThan(-1);// ORDER, not merely presence. `discard_archive!` deletes the .xcarchive,// and the dSYMs live inside it — a lane that discarded first would be// green, fast, and would have thrown away the only readable record of// every crash this build will ever produce.const discarded = body.indexOf("discard_archive!"); expect(discarded, `${lane} never discards its archive`).toBeGreaterThan(-1); expect( preserved,`${lane} discards the archive before preserving its dSYMs — the symbols go with it`, ).toBeLessThan(discarded); }); }// RULE: A shipped build keeps its own debug symbols, and a build that has none is refused rather than shipped. it("refuses an archive that carries no dSYM at all", () => {// A build that ships must be symbolicatable. Since nothing uploads symbols// anywhere, an archive with no dSYMs is a build whose crash reports are// hex addresses for ever — so the helper raises rather than warning.const text = fastfile();const start = text.indexOf("def preserve_dsyms!"); expect(start, "preserve_dsyms! is gone").toBeGreaterThan(-1);const body = text.slice(start, text.indexOf("\nend\n", start)); expect(body).toContain("UI.user_error!"); expect(body).toContain("found.empty?"); }); it("keeps them OUTSIDE the tree every workflow deletes", () => {// Each lane ends with `rm -rf build`. A dSYM under `build/` is therefore// deleted minutes after the upload it belongs to, and the runner has no// artifact backend to hand it to — this repo's workflows use// `actions/checkout` and nothing else, deliberately.const text = fastfile();const start = text.indexOf("def dsym_dir"); expect(start, "dsym_dir is gone").toBeGreaterThan(-1);const body = text.slice(start, text.indexOf("\nend\n", start)); expect(body).not.toContain('"build"'); expect(body).toContain("COTTON_DSYM_ROOT");// And the directory prunes itself: `disk-guard.sh` does not know about it,// so the cap lives with the writer or the boot disk fills. expect(text).toContain("def prune_dsyms!"); expect(text).toContain("COTTON_DSYM_KEEP"); });});describe("nothing uploads symbols anywhere", () => { it("the Fastfile runs no sentry-cli and needs no upload token", () => {const text = fastfileCode();// The retired symbolication flag and its switches. Matched as// ASSIGNMENTS, not mentions: the comment above `preserve_dsyms!` names// them to explain why they are gone, and a test that could not tell the// two apart would forbid the file from explaining itself.for (const name of ["COTTON_REQUIRE_SYMBOLICATION","SENTRY_DISABLE_AUTO_UPLOAD","SENTRY_ALLOW_FAILURE","SENTRY_AUTH_TOKEN", ]) { expect(text, name).not.toContain(`ENV["${name}"] =`); } expect(fastfileCode()).not.toContain("sentry-cli"); });for (const [file, ships] of WORKFLOWS) { it(`${file} supplies no symbol-upload secret${ships ? " (and it ships)" : ""}`, () => {const yml = read(".forgejo", "workflows", file);// Assignment form: a comment may — and does — still name these to say// why the workflow no longer carries them. expect(yml).not.toMatch(/^\s*SENTRY_AUTH_TOKEN:/m); expect(yml).not.toMatch(/^\s*SENTRY_DISABLE_AUTO_UPLOAD:/m);// `EXPO_PUBLIC_*` names nothing in this tree, and a secret with no// reader is a secret nobody notices has stopped being supplied. expect(yml).not.toMatch(/^\s*EXPO_PUBLIC_/m); }); }// RULE: Crash reports go to the self-hosted error service, never to a hosted one. it("no Sentry SaaS coordinate anywhere in the lane or its workflows", () => {// The original finding: a SaaS org this repo has no account on 404'd every// upload, twenty minutes into an archive on the build Mac. Nothing uploads// now, but a coordinate creeping back is how an upload comes back too.for (const saas of ["sentry.io", "means-of-production"]) { expect(fastfileCode(), saas).not.toContain(saas);for (const [file] of WORKFLOWS) { expect(read(".forgejo", "workflows", file), `${file}: ${saas}`).not.toContain(saas); } } });});/** * THE OTHER HALF: THE PHONE CARRIES ITS BUGSINK ADDRESS, AND THAT IS ALL. * * Nothing above changed when the phone got its sink (lane J2): there is still * no upload, no token and no sentry-cli. What a shipping build takes is ONE * value at build time — the DSN the app sends events to at RUNTIME — and it * travels as `COTTON_SENTRY_DSN`: exported by the shipping workflows from the * `COTTON_IOS_SENTRY_DSN` secret, passed to xcodebuild by the Fastfile as one * xcargs setting (the way the build number travels), read by the app's * Info.plist as `CottonSentryDSN` (the Mac's key), and EMPTY everywhere else * so a local build, a test host and a simulator report nothing. * * Each hop is pinned because each is a quiet failure: a workflow that stops * exporting it, a Fastfile that stops passing it, or a project that stops * reading it all produce a green build that reports nothing for ever. */describe("the phone carries its Bugsink address, and nothing else about Sentry", () => {const spec = () => read("apps", "cotton", "project.yml"); it("every shipping workflow exports the address from the one secret", () => {for (const [file, ships] of WORKFLOWS) {const yml = read(".forgejo", "workflows", file);const exported = /^\s*COTTON_SENTRY_DSN:\s*\$\{\{\s*secrets\.COTTON_IOS_SENTRY_DSN\s*\}\}\s*$/m;if (ships) { expect(yml, `${file} ships and does not export COTTON_SENTRY_DSN from the secret`).toMatch(exported); } else {// A dry run reaches nobody and needs no address; supplying one there// would be the first step of an upload creeping back. expect(yml, `${file} reaches nobody and should carry no address`).not.toMatch(/^\s*COTTON_SENTRY_DSN:/m); }// The Expo-era name is retired with the stack — as a secret reference too. expect(yml, `${file} names the retired Expo secret`).not.toContain("EXPO_PUBLIC_SENTRY_DSN"); } }); it("the Fastfile passes it to xcodebuild as one setting, and warns when it is missing", () => {const text = fastfileCode();const start = text.indexOf("def bugsink_xcarg"); expect(start, "bugsink_xcarg is gone").toBeGreaterThan(-1);const body = text.slice(start, text.indexOf("\nend\n", start)); expect(body).toContain('ENV["COTTON_SENTRY_DSN"]'); expect(body).toContain("COTTON_SENTRY_DSN=");// Loud when unset, and the build goes on: a phone with no error reporting// is still a phone a person can install. expect(body).toContain("UI.important("); expect(body).not.toContain("UI.user_error!(");// No fallback to a second name: one value, one name, one reader. expect(body).not.toContain("||"); expect(body).not.toContain("EXPO_PUBLIC");// And the shipping lane USES it, beside the build number it mirrors.const lane = text.indexOf("def ios_beta!");const laneBody = text.slice(lane, text.indexOf("\nend\n", lane)); expect(laneBody).toContain("bugsink_xcarg");// The lane builds through `archive_export!`, which takes the xcargs; the// DSN has to be in them by then.const build = laneBody.indexOf("archive_export!("); expect(build, "ios_beta! no longer builds through archive_export!").toBeGreaterThan(-1); expect(laneBody.indexOf("bugsink_xcarg")).toBeLessThan(build); }); it("the project reads it into the app's Info.plist under the Mac's key, and defaults it to nothing", () => {const text = spec();// The default: an empty string in the base settings, so an unstamped// build carries no address rather than a literal `$(COTTON_SENTRY_DSN)`. expect(text).toMatch(/^\s*COTTON_SENTRY_DSN:\s*""\s*$/m);// The app's plist reads it; the key is `BuildFacts.Key.dsn`'s.const plists = text.match(/^\s*CottonSentryDSN:\s*\$\(COTTON_SENTRY_DSN\)\s*$/gm) ?? []; expect(plists, "the app's Info.plist does not read the address").toHaveLength(1);// Nothing in the spec is an address. The value arrives at build time. expect(text).not.toMatch(/https:\/\/[0-9a-f]{16,}@/); }); it("the only third-party package is sentry-cocoa, pinned to the Mac's version", () => {const text = spec();const pins = text.match(/^\s*sentry-cocoa:\s*$\n\s*url:\s*(\S+)\s*$\n\s*exactVersion:\s*"?([0-9.]+)"?\s*$/m); expect(pins, "project.yml does not pin sentry-cocoa").not.toBeNull(); expect(pins?.[1]).toBe("https://github.com/getsentry/sentry-cocoa");// Read LOUDLY: the Mac executable declares it in apps/cotton/Package.swift, the one manifest, and a// regex over an empty read is a guard that went quiet, not red.const mac = read("apps", "cotton", "Package.swift");const macPin = mac.match(/sentry-cocoa",\s*exact:\s*"([0-9.]+)"/); expect(macPin, "the Mac's Package.swift no longer pins sentry-cocoa with `exact:`").not.toBeNull(); expect(pins?.[2], "the phone and the Mac pin different sentry-cocoa versions — one download, one cache").toBe(macPin?.[1]); });});