Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(hog): bundle source files with --include-source (#124577)

Rafael Audibertea8a15c58524
diff --git a/hog/README.md b/hog/README.md
index c37d37283bbd..3fbae1fe05ee 100644
--- a/hog/README.md
+++ b/hog/README.md
@@ -89,6 +89,7 @@ hog uploads the same bytes and content hashes as posthog-cli, so either CLI can
- `posthog-cli sourcemap`, `hermes`, `proguard`, `dsym` and `symbol-sets upload` are `hog error-tracking`, with paths as arguments instead of `--directory` and `--path`
- hog reads dSYM bundles itself, so it needs neither Xcode's `dwarfdump` nor `lipo`, and uploads dSYMs from Linux too
+- `--include-source` reads a binary's DWARF itself, with the same rules as posthog-cli, to bundle the source files it names. Where posthog-cli crashes on a malformed binary, hog uploads it without sources
- native releases come from the flags, `posthog.json` or git, as in `posthog-cli symbol-sets upload`. hog doesn't read the release from the dSYM's `Info.plist`, as `posthog-cli dsym upload` does
- `upload` sends only Hermes maps it detects. posthog-cli treats every JSON file in the folder as a map, and fails when it finds Metro's map there
- hog walks folders in sorted order and skips `node_modules`, `.git` and symlinks, so two machines visit the same files in the same order
diff --git a/hog/src/commands/error-tracking/error-tracking.test.ts b/hog/src/commands/error-tracking/error-tracking.test.ts
index 6998b938c433..d1500a30033f 100644
--- a/hog/src/commands/error-tracking/error-tracking.test.ts
+++ b/hog/src/commands/error-tracking/error-tracking.test.ts
@@ -276,6 +276,44 @@ describe('hog error-tracking upload', () => {
}
})
+ test('--include-source leaves out sources that match an ignore glob, also through a symlinked root', async () => {
+ // The fixture's DWARF names its sources under this folder.
+ const sources = '/tmp/hog-parity-native'
+ rmSync(sources, { recursive: true, force: true })
+ cpSync(join(NATIVE, '../src'), sources, { recursive: true })
+ cpSync(join(NATIVE, 'linux/checkout'), join(sources, 'bin/checkout'))
+ const plan = async (ignore: string[], linked = false): Promise<string> => {
+ const folder = project({})
+ if (linked) {
+ symlinkSync(sources, join(folder, 'linked'))
+ }
+ const path = linked ? 'linked' : sources
+ writeFileSync(
+ join(folder, 'posthog.json'),
+ JSON.stringify({ errorTracking: { sources: [{ path, ignore }] } })
+ )
+ const result = await runHog(['et', 'upload', '--dry-run', '--include-source'], {
+ env: { CLAUDECODE: '1' },
+ cwd: folder,
+ useDisk: true,
+ })
+ expect(result.exitCode).toBe(0)
+ return result.json().symbolSets[0].contentHash
+ }
+ try {
+ const all = await plan([])
+ rmSync(join(sources, 'checkout.c'))
+ const withoutCheckout = await plan([])
+ cpSync(join(NATIVE, '../src/checkout.c'), join(sources, 'checkout.c'))
+
+ expect(withoutCheckout).not.toBe(all)
+ expect(await plan(['checkout.c'])).toBe(withoutCheckout)
+ expect(await plan(['checkout.c'], true)).toBe(withoutCheckout)
+ } finally {
+ rmSync(sources, { recursive: true, force: true })
+ }
+ })
+
test('--dry-run reads the release from the repository a symlinked mapping points into', async () => {
const repository = project({ ...GIT_REPO, 'app/mapping.txt': SMALL_MAPPING })
const outside = project({})
diff --git a/hog/src/commands/error-tracking/shared.ts b/hog/src/commands/error-tracking/shared.ts
index dc3ae7f5d39a..20bc79069592 100644
--- a/hog/src/commands/error-tracking/shared.ts
+++ b/hog/src/commands/error-tracking/shared.ts
@@ -64,6 +64,11 @@ export const UPLOAD_OPTIONS = {
type: 'boolean',
description: 'JavaScript and CSS: remove sourcemap references and delete the maps after a successful upload',
},
+ includeSource: {
+ type: 'boolean',
+ description:
+ 'dSYM and native files: bundle the source files their debug info names, and replace what PostHog has',
+ },
batchSize: {
type: 'string',
placeholder: 'count',
@@ -90,6 +95,7 @@ interface RawOptions {
force?: boolean
skipOnConflict?: boolean
deleteAfter?: boolean
+ includeSource?: boolean
batchSize?: string
concurrency?: string
dryRun?: boolean
@@ -141,6 +147,7 @@ export function readOptions(options: RawOptions, env: Env): ErrorTrackingOptions
batchSize: options.batchSize === undefined ? undefined : count('--batch-size', options.batchSize, 50),
concurrency: count('--concurrency', options.concurrency ?? env.POSTHOG_CLI_SOURCEMAP_UPLOAD_CONCURRENCY, 10),
deleteAfter: options.deleteAfter === true,
+ includeSource: options.includeSource === true,
dryRun: options.dryRun === true,
}
}
diff --git a/hog/src/error-tracking/native/dwarf.ts b/hog/src/error-tracking/native/dwarf.ts
new file mode 100644
index 000000000000..a4a987f5e314
--- /dev/null
+++ b/hog/src/error-tracking/native/dwarf.ts
@@ -0,0 +1,706 @@
+// Header-only DWARF 2-5 reader: unit headers, abbreviations, the root DIE's attributes
+// and line-program headers. Semantics follow gimli 0.32 (the version posthog-cli links).
+
+import { Cursor, DwarfEof, DwarfError, strAt } from './bytes'
+import type { SectionReader } from './object'
+
+export const DW_TAG_compile_unit = 0x11
+export const DW_AT_name = 0x03
+export const DW_AT_stmt_list = 0x10
+export const DW_AT_low_pc = 0x11
+export const DW_AT_language = 0x13
+export const DW_AT_comp_dir = 0x1b
+export const DW_AT_ranges = 0x55
+export const DW_AT_str_offsets_base = 0x72
+export const DW_AT_addr_base = 0x73
+export const DW_AT_GNU_addr_base = 0x2133
+export const DW_LANG_Go = 0x16
+
+const F = {
+ addr: 0x01,
+ block2: 0x03,
+ block4: 0x04,
+ data2: 0x05,
+ data4: 0x06,
+ data8: 0x07,
+ string: 0x08,
+ block: 0x09,
+ block1: 0x0a,
+ data1: 0x0b,
+ flag: 0x0c,
+ sdata: 0x0d,
+ strp: 0x0e,
+ udata: 0x0f,
+ ref_addr: 0x10,
+ ref1: 0x11,
+ ref2: 0x12,
+ ref4: 0x13,
+ ref8: 0x14,
+ ref_udata: 0x15,
+ indirect: 0x16,
+ sec_offset: 0x17,
+ exprloc: 0x18,
+ flag_present: 0x19,
+ strx: 0x1a,
+ addrx: 0x1b,
+ ref_sup4: 0x1c,
+ strp_sup: 0x1d,
+ data16: 0x1e,
+ line_strp: 0x1f,
+ ref_sig8: 0x20,
+ implicit_const: 0x21,
+ loclistx: 0x22,
+ rnglistx: 0x23,
+ ref_sup8: 0x24,
+ strx1: 0x25,
+ strx2: 0x26,
+ strx3: 0x27,
+ strx4: 0x28,
+ addrx1: 0x29,
+ addrx2: 0x2a,
+ addrx3: 0x2b,
+ addrx4: 0x2c,
+ GNU_addr_index: 0x1f01,
+ GNU_str_index: 0x1f02,
+ GNU_ref_alt: 0x1f20,
+ GNU_strp_alt: 0x1f21,
+} as const
+
+// Attributes whose DW_FORM_data4/data8 is a section offset (gimli `allow_section_offset`).
+const SECTION_OFFSET_ATTRS = new Set([0x02, 0x10, 0x19, 0x2a, 0x2c, 0x40, 0x43, 0x79, 0x46, 0x48, 0x4a, 0x4d, 0x55])
+const DW_AT_data_member_location = 0x38
+
+export type AttrValue =
+ | { k: 'addr'; v: number }
+ | { k: 'data'; v: number } // data1/2/4/8 and udata
+ | { k: 'sdata'; v: number }
+ | { k: 'secoff'; v: number }
+ | { k: 'string'; v: Uint8Array }
+ | { k: 'strp'; v: number }
+ | { k: 'line_strp'; v: number }
+ | { k: 'strx'; v: number }
+ | { k: 'addrx'; v: number }
+ | { k: 'block'; v: Uint8Array }
+ | { k: 'other' }
+
+export interface Attr {
+ name: number
+ value: AttrValue
+}
+
+/** gimli `AttributeValue::udata_value`. */
+export function udataValue(v: AttrValue): number | null {
+ if (v.k === 'data') {
+ return v.v
+ }
+ if (v.k === 'sdata') {
+ return v.v < 0 ? null : v.v
+ }
+ return null
+}
+
+export interface Sections {
+ info: SectionReader
+ abbrev: Uint8Array
+ str: Uint8Array
+ lineStr: Uint8Array
+ strOffsets: Uint8Array
+ addr: Uint8Array
+ line: SectionReader
+ le: boolean
+}
+
+export interface UnitHeader {
+ offset: number
+ is64: boolean
+ version: number
+ unitType: number
+ addressSize: number
+ abbrevOffset: number
+ entries: Cursor
+ /** Absolute section range of the DIE bytes, used to re-read when the window was too small. */
+ entriesStart: number
+ entriesEnd: number
+ windowed: boolean
+}
+
+// Bytes read per unit up front: enough for the header and a root DIE in practice.
+const UNIT_WINDOW = 4096
+
+/**
+ * gimli `DebugInfoUnitHeadersIter`. Returns the headers parsed before the first error,
+ * and that error (symbolic fails the whole session on it, the CLI's pass 1 stops there).
+ */
+export function unitHeaders(s: Sections): { headers: UnitHeader[]; error: Error | null } {
+ const headers: UnitHeader[] = []
+ let offset = 0
+ try {
+ while (offset < s.info.size) {
+ // Read only a window per unit: the root DIE sits right after the header.
+ const pre = new Cursor(s.info.read(offset, 12), s.le)
+ const [length, is64] = pre.initialLength()
+ const lenSize = pre.pos
+ if (offset + lenSize + length > s.info.size) {
+ throw new DwarfEof()
+ }
+ const take = Math.min(length, UNIT_WINDOW)
+ const rest = new Cursor(s.info.read(offset + lenSize, take), s.le)
+ const windowed = take < length
+ const version = rest.u16()
+ let unitType = 1
+ let addressSize: number
+ let abbrevOffset: number
+ if (version >= 2 && version <= 4) {
+ abbrevOffset = rest.offset(is64)
+ addressSize = rest.addressSize()
+ } else if (version === 5) {
+ unitType = rest.u8()
+ addressSize = rest.addressSize()
+ abbrevOffset = rest.offset(is64)
+ switch (unitType) {
+ case 1: // compile
+ case 3: // partial
+ break
+ case 2: // type
+ case 6: // split_type
+ rest.u64() // type signature
+ rest.offset(is64) // type offset
+ break
+ case 4: // skeleton
+ case 5: // split_compile
+ rest.u64() // dwo_id
+ break
+ default:
+ throw new DwarfError(`unsupported unit type ${unitType}`)
+ }
+ } else {
+ throw new DwarfError(`unknown DWARF version ${version}`)
+ }
+ const entriesStart = offset + lenSize + rest.pos
+ const entriesEnd = offset + lenSize + length
+ headers.push({
+ offset,
+ is64,
+ version,
+ unitType,
+ addressSize,
+ abbrevOffset,
+ entries: rest,
+ entriesStart,
+ entriesEnd,
+ windowed,
+ })
+ offset = entriesEnd
+ }
+ } catch (e) {
+ return { headers, error: e as Error }
+ }
+ return { headers, error: null }
+}
+
+export interface AttrSpec {
+ name: number
+ form: number
+ implicit: number | null
+}
+export interface Abbrev {
+ tag: number
+ hasChildren: boolean
+ specs: AttrSpec[]
+}
+export type AbbrevTable = Map<number, Abbrev>
+
+/** gimli `Abbreviations::parse`, including its error cases. */
+export function parseAbbrevs(section: Uint8Array, offset: number, le: boolean): AbbrevTable {
+ const c = new Cursor(section, le)
+ c.skip(offset)
+ const table: AbbrevTable = new Map()
+ for (;;) {
+ if (c.isEmpty()) {
+ break
+ }
+ const code = c.uleb()
+ if (code === 0) {
+ break
+ }
+ const tag = c.uleb16()
+ if (tag === 0) {
+ throw new DwarfError('abbreviation tag zero')
+ }
+ const hc = c.u8()
+ if (hc > 1) {
+ throw new DwarfError('bad has_children')
+ }
+ const specs: AttrSpec[] = []
+ for (;;) {
+ const name = c.uleb16()
+ const form = c.uleb16()
+ if (name === 0) {
+ if (form !== 0) {
+ throw new DwarfError('expected zero')
+ }
+ break
+ }
+ if (form === 0) {
+ throw new DwarfError('attribute form zero')
+ }
+ const implicit = form === F.implicit_const ? c.sleb() : null
+ specs.push({ name, form, implicit })
+ }
+ if (table.has(code)) {
+ throw new DwarfError('duplicate abbreviation code')
+ }
+ table.set(code, { tag, hasChildren: hc === 1, specs })
+ }
+ return table
+}
+
+export class AbbrevCache {
+ private map = new Map<number, AbbrevTable | Error>()
+ constructor(private s: Sections) {}
+ get(offset: number): AbbrevTable {
+ let t = this.map.get(offset)
+ if (t === undefined) {
+ try {
+ t = parseAbbrevs(this.s.abbrev, offset, this.s.le)
+ } catch (e) {
+ t = e as Error
+ }
+ this.map.set(offset, t)
+ }
+ if (t instanceof Error) {
+ throw t
+ }
+ return t
+ }
+}
+
+export interface RootDie {
+ tag: number
+ attrs: Attr[]
+ /** Error hit while parsing attributes; `attrs` holds the ones parsed before it. */
+ attrError: Error | null
+}
+
+/**
+ * gimli `EntriesCursor::next_dfs` on a fresh cursor: skips null entries and returns the
+ * first real entry, or null when the unit has none (`MissingUnitDie`).
+ * Throws on an unknown abbreviation code or a truncated code.
+ */
+export function readRootDie(h: UnitHeader, abbrevs: AbbrevTable, info?: SectionReader): RootDie | null {
+ const die = readRootDieIn(new Cursor(h.entries.buf, h.entries.le, h.entries.pos, h.entries.end), h, abbrevs)
+ const truncated = die === null || die.attrError instanceof DwarfEof
+ if (h.windowed && truncated && info) {
+ // The window ended inside the root DIE: read the whole unit and parse again.
+ const full = info.read(h.entriesStart, h.entriesEnd - h.entriesStart)
+ return readRootDieIn(new Cursor(full, h.entries.le), h, abbrevs)
+ }
+ return die
+}
+
+function readRootDieIn(c: Cursor, h: UnitHeader, abbrevs: AbbrevTable): RootDie | null {
+ for (;;) {
+ if (c.isEmpty()) {
+ return null
+ }
+ const code = c.uleb()
+ if (code === 0) {
+ continue
+ }
+ const ab = abbrevs.get(code)
+ if (!ab) {
+ throw new DwarfError('unknown abbreviation')
+ }
+ const attrs: Attr[] = []
+ let attrError: Error | null = null
+ try {
+ for (const spec of ab.specs) {
+ attrs.push({ name: spec.name, value: parseAttr(c, h, spec) })
+ }
+ } catch (e) {
+ attrError = e as Error
+ }
+ return { tag: ab.tag, attrs, attrError }
+ }
+}
+
+/** gimli `parse_attribute` (unit.rs), with gimli's `Attribute::value` normalisation for the attributes we read. */
+function parseAttr(c: Cursor, h: UnitHeader, spec: AttrSpec): AttrValue {
+ let form = spec.form
+ for (;;) {
+ switch (form) {
+ case F.indirect:
+ form = c.uleb16()
+ continue
+ case F.addr:
+ return { k: 'addr', v: c.uint(h.addressSize) }
+ case F.block1:
+ return { k: 'block', v: c.split(c.u8()).buf }
+ case F.block2:
+ return { k: 'block', v: c.split(c.u16()).buf }
+ case F.block4:
+ return { k: 'block', v: c.split(c.u32()).buf }
+ case F.block:
+ case F.exprloc:
+ c.split(c.uleb())
+ return { k: 'other' }
+ case F.data1:
+ return { k: 'data', v: c.u8() }
+ case F.data2:
+ return { k: 'data', v: c.u16() }
+ case F.data4:
+ if (!h.is64 && allowSectionOffset(spec.name, h.version)) {
+ return { k: 'secoff', v: c.u32() }
+ }
+ return { k: 'data', v: c.u32() }
+ case F.data8:
+ if (h.is64 && allowSectionOffset(spec.name, h.version)) {
+ return { k: 'secoff', v: c.u64() }
+ }
+ return { k: 'data', v: c.u64() }
+ case F.data16:
+ c.split(16)
+ return { k: 'other' }
+ case F.udata:
+ return { k: 'data', v: c.uleb() }
+ case F.sdata:
+ return { k: 'sdata', v: c.sleb() }
+ case F.flag:
+ c.u8()
+ return { k: 'other' }
+ case F.flag_present:
+ return { k: 'other' }
+ case F.sec_offset:
+ return { k: 'secoff', v: c.offset(h.is64) }
+ case F.ref1:
+ c.u8()
+ return { k: 'other' }
+ case F.ref2:
+ c.u16()
+ return { k: 'other' }
+ case F.ref4:
+ case F.ref_sup4:
+ c.u32()
+ return { k: 'other' }
+ case F.ref8:
+ case F.ref_sig8:
+ case F.ref_sup8:
+ c.u64()
+ return { k: 'other' }
+ case F.ref_udata:
+ case F.loclistx:
+ case F.rnglistx:
+ c.uleb()
+ return { k: 'other' }
+ case F.ref_addr:
+ // DWARF 2 sized DW_FORM_ref_addr like an address.
+ if (h.version === 2) {
+ c.uint(h.addressSize)
+ } else {
+ c.offset(h.is64)
+ }
+ return { k: 'other' }
+ case F.GNU_ref_alt:
+ case F.strp_sup:
+ case F.GNU_strp_alt:
+ c.offset(h.is64)
+ return { k: 'other' }
+ case F.string:
+ return { k: 'string', v: c.cstr() }
+ case F.strp:
+ return { k: 'strp', v: c.offset(h.is64) }
+ case F.line_strp:
+ return { k: 'line_strp', v: c.offset(h.is64) }
+ case F.implicit_const:
+ if (spec.implicit === null) {
+ throw new DwarfError('invalid implicit const')
+ }
+ return { k: 'sdata', v: spec.implicit }
+ case F.strx:
+ case F.GNU_str_index:
+ return { k: 'strx', v: c.uleb() }
+ case F.strx1:
+ return { k: 'strx', v: c.u8() }
+ case F.strx2:
+ return { k: 'strx', v: c.u16() }
+ case F.strx3:
+ return { k: 'strx', v: c.uint(3) }
+ case F.strx4:
+ return { k: 'strx', v: c.u32() }
+ case F.addrx:
+ case F.GNU_addr_index:
+ return { k: 'addrx', v: c.uleb() }
+ case F.addrx1:
+ return { k: 'addrx', v: c.u8() }
+ case F.addrx2:
+ return { k: 'addrx', v: c.u16() }
+ case F.addrx3:
+ return { k: 'addrx', v: c.uint(3) }
+ case F.addrx4:
+ return { k: 'addrx', v: c.u32() }
+ default:
+ throw new DwarfError(`unknown form 0x${form.toString(16)}`)
+ }
+ }
+}
+
+function allowSectionOffset(name: number, version: number): boolean {
+ return SECTION_OFFSET_ATTRS.has(name) || (name === DW_AT_data_member_location && (version === 2 || version === 3))
+}
+
+/** gimli `DebuggingInformationEntry::attr_value`: first match, error if parsing failed before it. */
+export function firstAttr(die: RootDie, name: number): AttrValue | null {
+ for (const a of die.attrs) {
+ if (a.name === name) {
+ return a.value
+ }
+ }
+ if (die.attrError) {
+ throw die.attrError
+ }
+ return null
+}
+
+export interface StrCtx {
+ s: Sections
+ is64: boolean
+ strOffsetsBase: number
+ /** The CLI's pass 1 builds a gimli::Dwarf with an empty .debug_str_offsets. */
+ noStrOffsets?: boolean
+}
+
+/** gimli `Dwarf::attr_string(..).ok()`: the bytes of any string form, or null. */
+export function attrString(ctx: StrCtx, v: AttrValue): Uint8Array | null {
+ switch (v.k) {
+ case 'string':
+ return v.v
+ case 'strp':
+ return strAt(ctx.s.str, v.v)
+ case 'line_strp':
+ return strAt(ctx.s.lineStr, v.v)
+ case 'strx': {
+ if (ctx.noStrOffsets) {
+ return null
+ }
+ const size = ctx.is64 ? 8 : 4
+ const at = ctx.strOffsetsBase + v.v * size
+ if (at + size > ctx.s.strOffsets.length) {
+ return null
+ }
+ const off = new Cursor(ctx.s.strOffsets, ctx.s.le, at).offset(ctx.is64)
+ return strAt(ctx.s.str, off)
+ }
+ default:
+ return null
+ }
+}
+
+export interface LineFile {
+ path: AttrValue
+ dirIndex: number
+}
+export interface LineHeader {
+ version: number
+ compDir: Uint8Array | null
+ includeDirs: AttrValue[]
+ files: LineFile[]
+}
+
+/** gimli `LineProgramHeader::parse`; throws on the same malformations. */
+export function parseLineHeader(
+ s: Sections,
+ offset: number,
+ unitAddressSize: number,
+ compDir: Uint8Array | null
+): LineHeader {
+ if (offset > s.line.size) {
+ throw new DwarfEof()
+ }
+ const pre = new Cursor(s.line.read(offset, 32), s.le)
+ const [unitLength, is64] = pre.initialLength()
+ const lenSize = pre.pos
+ if (offset + lenSize + unitLength > s.line.size) {
+ throw new DwarfEof()
+ }
+ // Read the header only, never the line-number program that follows it.
+ const v = pre.remaining >= 2 ? pre.u16() : 0
+ const fixed = 2 + (v >= 5 ? 2 : 0) + (is64 ? 8 : 4)
+ let preHeaderLength = 0
+ if (pre.remaining >= fixed - 2) {
+ if (v >= 5) {
+ pre.skip(2)
+ }
+ preHeaderLength = pre.offset(is64)
+ }
+ // Unit lengths come from the file, so cap the read at the unit's end.
+ const take = Math.min(unitLength, fixed + preHeaderLength)
+ const rest = new Cursor(s.line.read(offset + lenSize, take), s.le)
+ const version = rest.u16()
+ if (version < 2 || version > 5) {
+ throw new DwarfError(`unknown line program version ${version}`)
+ }
+ let addressSize = unitAddressSize
+ if (version >= 5) {
+ addressSize = rest.addressSize()
+ if (rest.u8() !== 0) {
+ throw new DwarfError('unsupported segment size')
+ }
+ }
+ const headerLength = rest.offset(is64)
+ const hdr = rest.split(headerLength)
+ if (hdr.u8() === 0) {
+ throw new DwarfError('minimum instruction length zero')
+ }
+ const maxOps = version >= 4 ? hdr.u8() : 1
+ if (maxOps === 0) {
+ throw new DwarfError('maximum operations per instruction zero')
+ }
+ hdr.u8() // default_is_stmt
+ hdr.i8() // line_base
+ if (hdr.u8() === 0) {
+ throw new DwarfError('line range zero')
+ }
+ const opcodeBase = hdr.u8()
+ if (opcodeBase === 0) {
+ throw new DwarfError('opcode base zero')
+ }
+ hdr.split(opcodeBase - 1)
+
+ const enc = { is64, version, addressSize }
+ const includeDirs: AttrValue[] = []
+ const files: LineFile[] = []
+ if (version <= 4) {
+ for (;;) {
+ const d = hdr.cstr()
+ if (d.length === 0) {
+ break
+ }
+ includeDirs.push({ k: 'string', v: d })
+ }
+ for (;;) {
+ const p = hdr.cstr()
+ if (p.length === 0) {
+ break
+ }
+ const dirIndex = hdr.uleb()
+ hdr.uleb() // mtime
+ hdr.uleb() // length
+ files.push({ path: { k: 'string', v: p }, dirIndex })
+ }
+ return { version, compDir, includeDirs, files }
+ }
+ const dirFormat = entryFormat(hdr)
+ const dirCount = hdr.uleb()
+ for (let i = 0; i < dirCount; i++) {
+ let path: AttrValue | null = null
+ for (const f of dirFormat) {
+ const v = lineAttr(hdr, enc, f.form)
+ if (f.type === 1) {
+ path = v
+ }
+ }
+ includeDirs.push(path!)
+ }
+ const fileFormat = entryFormat(hdr)
+ const fileCount = hdr.uleb()
+ for (let i = 0; i < fileCount; i++) {
+ let path: AttrValue | null = null
+ let dirIndex = 0
+ for (const f of fileFormat) {
+ const v = lineAttr(hdr, enc, f.form)
+ if (f.type === 1) {
+ path = v
+ } else if (f.type === 2) {
+ dirIndex = udataValue(v) ?? dirIndex
+ }
+ }
+ files.push({ path: path!, dirIndex })
+ }
+ // DWARF 5 has no implicit compilation directory; index 0 is an explicit entry.
+ return { version, compDir: null, includeDirs, files }
+}
+
+function entryFormat(c: Cursor): { type: number; form: number }[] {
+ const count = c.u8()
+ const out: { type: number; form: number }[] = []
+ let paths = 0
+ for (let i = 0; i < count; i++) {
+ const type = Math.min(c.uleb(), 0xffff)
+ if (type === 1) {
+ paths++
+ }
+ out.push({ type, form: c.uleb16() })
+ }
+ if (paths !== 1) {
+ throw new DwarfError('missing file entry format path')
+ }
+ return out
+}
+
+/** gimli `parse_attribute` in line.rs: a narrower form set, no section-offset promotion. */
+function lineAttr(c: Cursor, enc: { is64: boolean }, form: number): AttrValue {
+ switch (form) {
+ case F.block1:
+ return { k: 'block', v: c.split(c.u8()).buf }
+ case F.block2:
+ return { k: 'block', v: c.split(c.u16()).buf }
+ case F.block4:
+ return { k: 'block', v: c.split(c.u32()).buf }
+ case F.block:
+ return { k: 'block', v: c.split(c.uleb()).buf }
+ case F.data1:
+ return { k: 'data', v: c.u8() }
+ case F.data2:
+ return { k: 'data', v: c.u16() }
+ case F.data4:
+ return { k: 'data', v: c.u32() }
+ case F.data8:
+ return { k: 'data', v: c.u64() }
+ case F.data16:
+ c.split(16)
+ return { k: 'other' }
+ case F.udata:
+ return { k: 'data', v: c.uleb() }
+ case F.sdata:
+ return { k: 'sdata', v: c.sleb() }
+ case F.flag:
+ c.u8()
+ return { k: 'other' }
+ case F.sec_offset:
+ return { k: 'secoff', v: c.offset(enc.is64) }
+ case F.string:
+ return { k: 'string', v: c.cstr() }
+ case F.strp:
+ return { k: 'strp', v: c.offset(enc.is64) }
+ case F.strp_sup:
+ case F.GNU_strp_alt:
+ c.offset(enc.is64)
+ return { k: 'other' }
+ case F.line_strp:
+ return { k: 'line_strp', v: c.offset(enc.is64) }
+ case F.strx:
+ case F.GNU_str_index:
+ return { k: 'strx', v: c.uleb() }
+ case F.strx1:
+ return { k: 'strx', v: c.u8() }
+ case F.strx2:
+ return { k: 'strx', v: c.u16() }
+ case F.strx3:
+ return { k: 'strx', v: c.uint(3) }
+ case F.strx4:
+ return { k: 'strx', v: c.u32() }
+ default:
+ throw new DwarfError(`unknown line form 0x${form.toString(16)}`)
+ }
+}
+
+/** gimli `LineProgramHeader::directory`: DWARF <= 4 index 0 is the unit's comp dir. */
+export function fileDirectory(h: LineHeader, index: number): AttrValue | null {
+ if (h.version <= 4) {
+ if (index === 0) {
+ return h.compDir ? { k: 'string', v: h.compDir } : null
+ }
+ return h.includeDirs[index - 1] ?? null
+ }
+ return h.includeDirs[index] ?? null
+}
diff --git a/hog/src/error-tracking/native/package.ts b/hog/src/error-tracking/native/package.ts
index d560cdb2a984..82d2bcdb32dd 100644
--- a/hog/src/error-tracking/native/package.ts
+++ b/hog/src/error-tracking/native/package.ts
@@ -90,6 +90,8 @@ export interface DsymSlice {
uuid: string
path: string
data: Uint8Array
+ // The whole file the slice came from, which source collection reads.
+ file: Uint8Array
}
// What `dwarfdump --uuid` and `lipo -thin` give posthog-cli: every slice of every binary in the
@@ -115,7 +117,7 @@ export function dsymSlices(bundle: string, include: (path: string) => boolean =
const [object] = openArchive(new BufferSource(part))
const uuid = object?.debugId()
if (object?.format === 'macho' && uuid) {
- slices.push({ uuid: uuid.toUpperCase(), path, data: part })
+ slices.push({ uuid: uuid.toUpperCase(), path, data: part, file: bytes })
}
}
}
diff --git a/hog/src/error-tracking/native/path.ts b/hog/src/error-tracking/native/path.ts
new file mode 100644
index 000000000000..6aaad18cd107
--- /dev/null
+++ b/hog/src/error-tracking/native/path.ts
@@ -0,0 +1,116 @@
+// Port of symbolic-common 12.x `join_path` and `clean_path` (src/path.rs), Windows rules included.
+
+const isSep = (c: string | undefined): boolean => c === '/' || c === '\\'
+
+function isWindowsUnc(p: string): boolean {
+ return p.startsWith('\\\\') || p.startsWith('//')
+}
+
+function isWindowsDriveLetter(p: string): boolean {
+ const d = p.charCodeAt(0)
+ const alpha = (d >= 0x41 && d <= 0x5a) || (d >= 0x61 && d <= 0x7a)
+ return alpha && p[1] === ':' && (p.length === 2 || isSep(p[2]))
+}
+
+const isAbsoluteWindows = (p: string): boolean => isWindowsUnc(p) || isWindowsDriveLetter(p)
+const isSemiAbsoluteWindows = (p: string): boolean => isSep(p[0])
+const isAbsoluteUnix = (p: string): boolean => p[0] === '/'
+const isWindowsPath = (p: string): boolean => isAbsoluteWindows(p) || p.includes('\\')
+
+function trimEndSeps(s: string): string {
+ let e = s.length
+ while (e > 0 && isSep(s[e - 1])) {
+ e--
+ }
+ return s.slice(0, e)
+}
+
+function trimStartSeps(s: string): string {
+ let b = 0
+ while (b < s.length && isSep(s[b])) {
+ b++
+ }
+ return s.slice(b)
+}
+
+export function joinPath(base: string, other: string): string {
+ if (other.startsWith('<') && other.endsWith('>')) {
+ return other
+ }
+ if (base === '' || isAbsoluteWindows(other) || isAbsoluteUnix(other)) {
+ return other
+ }
+ if (other === '') {
+ return base
+ }
+ if (isSemiAbsoluteWindows(other)) {
+ // C:\test + \bar -> C:\bar
+ return isAbsoluteWindows(base) ? base.slice(0, 2) + other : other
+ }
+ const win = isWindowsPath(base) || isWindowsPath(other)
+ return trimEndSeps(base) + (win ? '\\' : '/') + trimStartSeps(other)
+}
+
+function rfindSep(s: string): number {
+ for (let i = s.length - 1; i >= 0; i--) {
+ if (isSep(s[i])) {
+ return i
+ }
+ }
+ return -1
+}
+
+export function cleanPath(path: string): string {
+ let rv = ''
+ const sep = isWindowsPath(path) ? '\\' : '/'
+ let needsSeparator = false
+ let isPastRoot = false
+
+ // Rust `split_terminator`: like split, minus one trailing empty segment.
+ const segments = path.split(/[\\/]/)
+ if (segments.length > 0 && segments[segments.length - 1] === '') {
+ segments.pop()
+ }
+
+ for (const segment of segments) {
+ if (segment === '.') {
+ continue
+ }
+ if (segment === '..') {
+ let popped = false
+ if (!isPastRoot) {
+ const idx = rfindSep(rv)
+ if (idx >= 0) {
+ rv = rv.slice(0, idx)
+ popped = true
+ } else if (rv !== '') {
+ rv = ''
+ popped = true
+ }
+ }
+ if (popped) {
+ if (rv === '') {
+ needsSeparator = false
+ }
+ } else {
+ if (!isPastRoot) {
+ needsSeparator = false
+ isPastRoot = true
+ }
+ if (needsSeparator) {
+ rv += sep
+ }
+ rv += '..'
+ needsSeparator = true
+ }
+ continue
+ }
+ if (needsSeparator) {
+ rv += sep
+ } else {
+ needsSeparator = true
+ }
+ rv += segment
+ }
+ return rv
+}
diff --git a/hog/src/error-tracking/native/sources.test.ts b/hog/src/error-tracking/native/sources.test.ts
new file mode 100644
index 000000000000..81d5cada994f
--- /dev/null
+++ b/hog/src/error-tracking/native/sources.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, test } from 'bun:test'
+import { mkdtempSync, symlinkSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+
+import { collectSources, fileName, zipRelativePaths } from './sources'
+
+// The parity fixtures name no two sources alike and hold no symlinks, so these cases cover the
+// collision rounds and the read refusals that posthog-cli's own unit tests cover.
+describe('source bundles', () => {
+ test.each([
+ ['distinct names stay file names', ['/src/a.c', '/src/b.c'], ['a.c', 'b.c']],
+ [
+ 'shared names take parents until they differ',
+ ['/a/x/f.c', '/b/x/f.c', '/c/g.c'],
+ ['a/x/f.c', 'b/x/f.c', 'g.c'],
+ ],
+ [
+ 'dot components never reach a zip name',
+ ['/a/../conflict.go', '/a/b/conflict.go'],
+ ['a/conflict.go', 'b/conflict.go'],
+ ],
+ ['a path with no file name is unknown', ['/'], ['unknown']],
+ ])('%s', (_name, paths, expected) => {
+ expect(zipRelativePaths(paths)).toEqual(expected)
+ })
+
+ test.each([
+ ['C:\\workspace\\app\\main.go', 'win32', 'main.go'],
+ ['C:\\workspace\\app\\main.go', 'linux', 'C:\\workspace\\app\\main.go'],
+ ['/workspace/app/main.go', 'win32', 'main.go'],
+ ] as const)('the file name of %s on %s is %s', (path, platform, expected) => {
+ expect(fileName(path, platform)).toBe(expected)
+ })
+
+ test.skipIf(process.platform === 'win32')('a FIFO is refused without waiting for a writer', () => {
+ const folder = mkdtempSync(join(tmpdir(), 'hog-sources-'))
+ Bun.spawnSync(['mkfifo', join(folder, 'pipe.c')])
+ const warnings: string[] = []
+
+ collectSources([join(folder, 'pipe.c')], warnings)
+
+ expect(warnings).toEqual([expect.stringContaining('not a regular file')])
+ })
+
+ test('a symlinked source is refused, and the real file is read', () => {
+ const folder = mkdtempSync(join(tmpdir(), 'hog-sources-'))
+ writeFileSync(join(folder, 'secret'), 'sensitive')
+ symlinkSync(join(folder, 'secret'), join(folder, 'legit.go'))
+ const warnings: string[] = []
+
+ const bundle = collectSources([join(folder, 'legit.go'), join(folder, 'secret')], warnings)
+
+ expect([...bundle.manifest.keys()]).toEqual([join(folder, 'secret')])
+ expect(warnings).toEqual([expect.stringContaining('path is a symlink')])
+ })
+})
diff --git a/hog/src/error-tracking/native/sources.ts b/hog/src/error-tracking/native/sources.ts
new file mode 100644
index 000000000000..c58fe49f1855
--- /dev/null
+++ b/hog/src/error-tracking/native/sources.ts
@@ -0,0 +1,192 @@
+import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, realpathSync } from 'node:fs'
+
+import { compareUtf8, writeString } from '../json'
+import { BufferSource, type Source } from './object'
+import { extractSourcePaths, filterNativeSourcePaths, filterSourcePaths } from './walk'
+import type { ZipWriter } from './zip'
+
+// `--include-source`: the source files the DWARF names go into the zip under `__source/`, with a
+// manifest from DWARF path to zip path. posthog-cli's dsym/source_bundle.rs.
+
+const MAX_SOURCE_FILE_BYTES = 64 * 1024 * 1024
+const MAX_ZIP_ENTRIES = 0xffff
+
+export interface SourceBundle {
+ manifest: Map<string, string>
+ // Zip path to bytes. A later file with the same zip path replaces the earlier bytes.
+ contents: Map<string, Uint8Array>
+}
+
+// Rust's `Path::file_name`: the last normal component, ignoring trailing separators and `.`
+// components, and none for `..`, `/` or an empty path. Windows also splits on `\`.
+export function fileName(path: string, platform: NodeJS.Platform = process.platform): string | null {
+ const parts = path.split(platform === 'win32' ? /[\\/]/ : '/').filter((part) => part !== '' && part !== '.')
+ const last = parts[parts.length - 1]
+ return last === undefined || last === '..' ? null : last
+}
+
+// `build_zip_relative_paths`: start from file names, then give every name shared by several files
+// one more parent directory per round, for at most 10 rounds.
+export function zipRelativePaths(paths: string[]): string[] {
+ const result = paths.map((path) => fileName(path) ?? 'unknown')
+ for (let round = 0; round < 10; round++) {
+ const groups = new Map<string, number[]>()
+ result.forEach((name, index) => {
+ const group = groups.get(name)
+ if (group) {
+ group.push(index)
+ } else {
+ groups.set(name, [index])
+ }
+ })
+ let duplicates = false
+ for (const indices of groups.values()) {
+ if (indices.length < 2) {
+ continue
+ }
+ duplicates = true
+ for (const index of indices) {
+ // Dot components never disambiguate, and `..` would let a crafted DWARF path escape
+ // `__source/` when the zip is extracted.
+ const components = paths[index]!.split('/').filter(
+ (part) => part !== '' && part !== '.' && part !== '..'
+ )
+ const depth = Math.min(result[index]!.split('/').length + 1, components.length)
+ result[index] = components.slice(components.length - depth).join('/')
+ }
+ }
+ if (!duplicates) {
+ break
+ }
+ }
+ return result
+}
+
+// `read_source_file`: a DWARF path can point anywhere, so symlinks, devices and files over 64 MiB
+// are refused, and the checks run on the opened file. O_NONBLOCK keeps the open of a FIFO
+// without a writer from hanging before the regular-file check rejects it.
+function readSourceFile(path: string): Uint8Array {
+ if (lstatSync(path).isSymbolicLink()) {
+ throw new Error('path is a symlink')
+ }
+ const descriptor = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK)
+ try {
+ const stat = fstatSync(descriptor)
+ if (!stat.isFile()) {
+ throw new Error('not a regular file')
+ }
+ if (stat.size > MAX_SOURCE_FILE_BYTES) {
+ throw new Error('exceeds the source file size limit')
+ }
+ // Like Rust's `take(MAX + 1)`, a file that grew since the stat is read up to the cap.
+ let buffer = Buffer.alloc(stat.size + 1)
+ let total = 0
+ for (;;) {
+ if (total === buffer.length) {
+ if (total > MAX_SOURCE_FILE_BYTES) {
+ throw new Error('exceeds the source file size limit')
+ }
+ const grown = Buffer.alloc(Math.min(buffer.length * 2, MAX_SOURCE_FILE_BYTES + 1))
+ buffer.copy(grown)
+ buffer = grown
+ }
+ const count = readSync(descriptor, buffer, total, buffer.length - total, null)
+ if (count === 0) {
+ return buffer.subarray(0, total)
+ }
+ total += count
+ }
+ } finally {
+ closeSync(descriptor)
+ }
+}
+
+// `collect_source_files`. Files that can't be read are reported and left out, and the manifest is
+// written even when every read failed.
+export function collectSources(paths: string[], warnings: string[]): SourceBundle {
+ const bundle: SourceBundle = { manifest: new Map(), contents: new Map() }
+ zipRelativePaths(paths).forEach((relative, index) => {
+ const path = paths[index]!
+ try {
+ const data = readSourceFile(path)
+ const zipPath = `__source/${relative}`
+ bundle.manifest.set(path, zipPath)
+ bundle.contents.set(zipPath, data)
+ } catch (error) {
+ warnings.push(`hog couldn't read the source file ${path}, so it isn't bundled: ${(error as Error).message}`)
+ }
+ })
+ return bundle
+}
+
+// `serde_json::to_vec_pretty` of `SourceManifest { version, files: BTreeMap }`.
+function manifestJson(manifest: Map<string, string>): string {
+ const entries = [...manifest].sort(([a], [b]) => compareUtf8(a, b))
+ const files =
+ entries.length === 0
+ ? '{}'
+ : `{\n${entries.map(([key, value]) => ` ${writeString(key)}: ${writeString(value)}`).join(',\n')}\n }`
+ return `{\n "version": 1,\n "files": ${files}\n}`
+}
+
+// `add_source_to_zip`: the manifest, then every file in zip-path byte order.
+export function addSources(zip: ZipWriter, bundle: SourceBundle): void {
+ zip.add('__source/manifest.json', Buffer.from(manifestJson(bundle.manifest), 'utf8'))
+ for (const [path, data] of [...bundle.contents].sort(([a], [b]) => compareUtf8(a, b))) {
+ zip.add(path, data)
+ }
+}
+
+export type SourceFilter = 'dsym' | 'native'
+
+// The source paths of one binary, filtered as `dsym upload` or `symbol-sets upload` filters them.
+// A DWARF error means no sources. posthog-cli logs the same and uploads the binary alone.
+export function sourcePaths(source: Source, filter: SourceFilter, warnings: string[]): string[] {
+ let all: string[]
+ try {
+ all = extractSourcePaths(source)
+ } catch (error) {
+ warnings.push(
+ `hog couldn't read the source paths from the DWARF, so it uploads without sources: ${(error as Error).message}`
+ )
+ return []
+ }
+ return filter === 'dsym' ? filterSourcePaths(all) : filterNativeSourcePaths(all)
+}
+
+// Kernel-backed files hold no source code, but some hold secrets, like /proc/self/environ. Their
+// bytes change with every process, so posthog-cli can never upload the same ones.
+const VIRTUAL_FILESYSTEMS = ['/proc/', '/sys/', '/dev/']
+const isVirtual = (path: string): boolean => {
+ let real: string
+ try {
+ real = realpathSync(path)
+ } catch {
+ return false
+ }
+ return VIRTUAL_FILESYSTEMS.some((prefix) => real.startsWith(prefix))
+}
+
+export function sourceStep(
+ bytes: Uint8Array,
+ filter: SourceFilter,
+ warnings: string[],
+ ignored: (path: string) => boolean
+): ((zip: ZipWriter) => void) | undefined {
+ const paths = sourcePaths(new BufferSource(bytes), filter, warnings).filter(
+ (path) => !ignored(path) && !isVirtual(path)
+ )
+ if (paths.length === 0) {
+ return undefined
+ }
+ const bundle = collectSources(paths, warnings)
+ // The sources, the manifest and the binary must fit a zip without ZIP64. posthog-cli's zip
+ // crate switches to ZIP64 there, which hog doesn't write, so it uploads the binary alone.
+ if (bundle.contents.size + 2 > MAX_ZIP_ENTRIES) {
+ warnings.push(
+ `The binary names ${bundle.contents.size} source files, more than one upload can hold, so hog uploads it without sources.`
+ )
+ return undefined
+ }
+ return (zip) => addSources(zip, bundle)
+}
diff --git a/hog/src/error-tracking/native/walk.ts b/hog/src/error-tracking/native/walk.ts
new file mode 100644
index 000000000000..1399788bb615
--- /dev/null
+++ b/hog/src/error-tracking/native/walk.ts
@@ -0,0 +1,387 @@
+// The posthog-cli source-path walk: `extract_source_paths_from_dwarf_bytes`,
+// `filter_source_paths` and `filter_native_source_paths`.
+
+import { DwarfError, utf8Lossy, utf8Strict } from './bytes'
+import {
+ AbbrevCache,
+ type AttrValue,
+ DW_AT_addr_base,
+ DW_AT_comp_dir,
+ DW_AT_GNU_addr_base,
+ DW_AT_language,
+ DW_AT_low_pc,
+ DW_AT_name,
+ DW_AT_ranges,
+ DW_AT_stmt_list,
+ DW_AT_str_offsets_base,
+ DW_LANG_Go,
+ DW_TAG_compile_unit,
+ type Sections,
+ type StrCtx,
+ attrString,
+ fileDirectory,
+ firstAttr,
+ parseLineHeader,
+ readRootDie,
+ udataValue,
+ unitHeaders,
+} from './dwarf'
+import { type NativeObject, type Source, bufferReader, openArchive } from './object'
+import { cleanPath, joinPath } from './path'
+
+const EXCLUDED_SYNTHETIC_NAMES = [
+ '/_AvailabilityInternal',
+ '/_Builtin_',
+ '/_DarwinFoundation',
+ '/CFNetwork',
+ '/CoreFoundation',
+ '/Darwin',
+ '/Dispatch',
+ '/Foundation',
+ '/MachO',
+ '/ObjectiveC',
+ '/Security',
+ '/XPC',
+ '/asl',
+ '/os_',
+ '/ptrcheck',
+ '/ptrauth',
+ '<stdin>',
+ '<swift-imported-modules>',
+]
+const EXCLUDED_PREFIXES = ['/usr/', '/Library/Developer/', '/Applications/Xcode', '/System/']
+const EXCLUDED_SUBSTRINGS = ['/Xcode.app/', '/SDKs/', '<compiler-generated>', '<built-in>', '/DerivedData/']
+const NATIVE_EXCLUDED = ['/.cargo/registry/', '/.cargo/git/', '/rustc/', '/.rustup/toolchains/', '/vendor/']
+const GOROOT_WITNESSES = ['runtime/proc.go', 'runtime/malloc.go', 'runtime/mgc.go', 'runtime/runtime2.go']
+
+const EMPTY = new Uint8Array(0)
+
+function loadSections(obj: NativeObject, names: (keyof Omit<Sections, 'le' | 'info' | 'line'>)[]): Sections {
+ const map: Record<string, string> = {
+ info: 'debug_info',
+ abbrev: 'debug_abbrev',
+ str: 'debug_str',
+ lineStr: 'debug_line_str',
+ strOffsets: 'debug_str_offsets',
+ addr: 'debug_addr',
+ line: 'debug_line',
+ }
+ const s: Sections = {
+ info: obj.window('debug_info') ?? bufferReader(EMPTY),
+ abbrev: EMPTY,
+ str: EMPTY,
+ lineStr: EMPTY,
+ strOffsets: EMPTY,
+ addr: EMPTY,
+ line: obj.window('debug_line') ?? bufferReader(EMPTY),
+ le: obj.littleEndian,
+ }
+ for (const n of names) {
+ s[n] = obj.section(map[n]!) ?? EMPTY
+ }
+ return s
+}
+
+interface CuInfo {
+ mainFiles: string[]
+ hasGo: boolean
+}
+
+/** `cu_main_files_from_dwarf`: root DIEs only, strict UTF-8, no .debug_str_offsets. */
+function cuMainFiles(obj: NativeObject): CuInfo {
+ const s = loadSections(obj, ['abbrev', 'str', 'lineStr'])
+ const out: CuInfo = { mainFiles: [], hasGo: false }
+ const abbrevs = new AbbrevCache(s)
+ const { headers } = unitHeaders(s) // an iteration error just ends the walk
+ for (const h of headers) {
+ let root
+ try {
+ root = readRootDie(h, abbrevs.get(h.abbrevOffset), s.info)
+ } catch {
+ continue
+ }
+ if (!root || root.tag !== DW_TAG_compile_unit) {
+ continue
+ }
+
+ const get = (name: number): AttrValue | null => {
+ try {
+ return firstAttr(root, name)
+ } catch {
+ return null
+ }
+ }
+ const lang = get(DW_AT_language)
+ const langCode = lang ? udataValue(lang) : null
+ if (langCode === DW_LANG_Go) {
+ out.hasGo = true
+ continue
+ }
+ const ctx: StrCtx = { s, is64: h.is64, strOffsetsBase: 0, noStrOffsets: true }
+ const resolve = (v: AttrValue | null): string | null => {
+ if (!v || (v.k !== 'string' && v.k !== 'strp' && v.k !== 'line_strp')) {
+ return null
+ }
+ const b = attrString(ctx, v)
+ return b ? utf8Strict(b) : null
+ }
+ const compDir = resolve(get(DW_AT_comp_dir))
+ const name = resolve(get(DW_AT_name))
+
+ let path: string
+ if (name !== null && name.startsWith('<')) {
+ continue
+ } else if (compDir !== null && name !== null && !name.startsWith('/')) {
+ path = `${compDir.replace(/\/+$/, '')}/${name}`
+ } else if (name !== null && name.startsWith('/')) {
+ path = name
+ } else if (compDir !== null && name === null) {
+ path = compDir
+ } else {
+ continue
+ }
+ if (path !== '') {
+ out.mainFiles.push(path)
+ }
+ }
+ out.mainFiles = out.mainFiles.filter(
+ (p) =>
+ !EXCLUDED_SYNTHETIC_NAMES.some((x) => p.startsWith(x)) &&
+ !EXCLUDED_PREFIXES.some((x) => p.startsWith(x)) &&
+ !EXCLUDED_SUBSTRINGS.some((x) => p.includes(x))
+ )
+ return out
+}
+
+/** `longest_common_prefix`: common directory prefix, compared per Unicode scalar value. */
+export function longestCommonPrefix(paths: string[]): string | null {
+ if (paths.length === 0) {
+ return null
+ }
+ const dirs = paths.map((p) => {
+ const i = p.lastIndexOf('/')
+ return i >= 0 ? p.slice(0, i + 1) : '/'
+ })
+ const first = dirs[0]!
+ let prefixLen = first.length
+ for (const dir of dirs.slice(1)) {
+ // Walk both strings by code point; `end` is a UTF-16 index into `first`.
+ let i = 0
+ let j = 0
+ let end = 0
+ while (i < first.length && j < dir.length) {
+ const a = first.codePointAt(i)!
+ const b = dir.codePointAt(j)!
+ if (a !== b) {
+ break
+ }
+ i += a > 0xffff ? 2 : 1
+ j += b > 0xffff ? 2 : 1
+ end = i
+ }
+ const newLen = first.slice(0, end).lastIndexOf('/') + 1
+ prefixLen = Math.min(prefixLen, newLen)
+ }
+ return prefixLen === 0 ? null : first.slice(0, prefixLen)
+}
+
+/**
+ * symbolic `DwarfDebugSession::files()` and `FileEntry::abs_path_str()`.
+ * Calls `onPath` per file entry; throws where symbolic yields an error.
+ */
+function sessionFiles(obj: NativeObject, onPath: (p: string) => void): void {
+ // symbolic's DwarfSections loads these too; only their lookup can fail (ELF bounds panic).
+ for (const n of ['debug_aranges', 'debug_ranges', 'debug_rnglists', 'debug_macinfo', 'debug_macro']) {
+ obj.probe(n)
+ }
+ const s = loadSections(obj, ['abbrev', 'str', 'lineStr', 'strOffsets', 'addr'])
+ const { headers, error } = unitHeaders(s)
+ if (error) {
+ throw error
+ } // DwarfInfo::parse collects all headers up front
+ const abbrevs = new AbbrevCache(s)
+ for (const h of headers) {
+ // gimli `Unit::new`
+ const root = readRootDie(h, abbrevs.get(h.abbrevOffset), s.info)
+ if (!root) {
+ continue
+ } // MissingUnitDie is skipped silently
+ if (root.attrError) {
+ throw root.attrError
+ }
+ let name: AttrValue | null = null
+ let compDir: AttrValue | null = null
+ let lowPc: AttrValue | null = null
+ let stmtList: number | null = null
+ let strOffsetsBase = 0
+ let addrBase = 0
+ for (const a of root.attrs) {
+ if (a.name === DW_AT_name) {
+ name = a.value
+ } else if (a.name === DW_AT_comp_dir) {
+ compDir = a.value
+ } else if (a.name === DW_AT_low_pc) {
+ lowPc = a.value
+ } else if (a.name === DW_AT_stmt_list && a.value.k === 'secoff') {
+ stmtList = a.value.v
+ } else if (a.name === DW_AT_str_offsets_base && a.value.k === 'secoff') {
+ strOffsetsBase = a.value.v
+ } else if ((a.name === DW_AT_addr_base || a.name === DW_AT_GNU_addr_base) && a.value.k === 'secoff') {
+ addrBase = a.value.v
+ }
+ }
+ const ctx: StrCtx = { s, is64: h.is64, strOffsetsBase }
+ const nameBytes = name ? attrString(ctx, name) : null
+ const compDirBytes = compDir ? attrString(ctx, compDir) : null
+ const line = stmtList === null ? null : parseLineHeader(s, stmtList, h.addressSize, compDirBytes)
+ void nameBytes // gimli passes the name for the DWARF <= 4 comp_file, which files() never visits
+ let lowPcValue = 0
+ if (lowPc?.k === 'addr') {
+ lowPcValue = lowPc.v
+ } else if (lowPc?.k === 'addrx') {
+ const at = addrBase + lowPc.v * h.addressSize
+ if (at + h.addressSize > s.addr.length) {
+ throw new DwarfError('debug_addr index out of range')
+ }
+ lowPcValue = readAddr(s, at, h.addressSize)
+ }
+
+ // symbolic `DwarfUnit::from_unit`: skip units the linker emptied.
+ const hasRanges = root.attrs.some((a) => a.name === DW_AT_ranges)
+ if (!obj.relocatable && lowPcValue === 0 && !hasRanges) {
+ continue
+ }
+ if (!line) {
+ continue
+ }
+
+ const compDirStr = compDirBytes ? utf8Lossy(compDirBytes) : ''
+ for (const f of line.files) {
+ const dirAttr = fileDirectory(line, f.dirIndex)
+ const dir = dirAttr ? attrString(ctx, dirAttr) : null
+ const fname = attrString(ctx, f.path)
+ const joined = joinPath(dir ? utf8Lossy(dir) : '', fname ? utf8Lossy(fname) : '')
+ onPath(cleanPath(joinPath(compDirStr, joined)))
+ }
+ }
+}
+
+function readAddr(s: Sections, at: number, size: number): number {
+ const dv = new DataView(s.addr.buffer, s.addr.byteOffset + at, size)
+ if (size === 1) {
+ return dv.getUint8(0)
+ }
+ if (size === 2) {
+ return dv.getUint16(0, s.le)
+ }
+ if (size === 4) {
+ return dv.getUint32(0, s.le)
+ }
+ const lo = dv.getUint32(s.le ? 0 : 4, s.le)
+ const hi = dv.getUint32(s.le ? 4 : 0, s.le)
+ return hi * 0x1_0000_0000 + lo
+}
+
+/** `is_bundleable_go_source`. */
+export function isBundleableGoSource(path: string): boolean {
+ const c0 = path.charCodeAt(0)
+ const absolute =
+ path.startsWith('/') ||
+ (path.length > 2 &&
+ ((c0 >= 0x41 && c0 <= 0x5a) || (c0 >= 0x61 && c0 <= 0x7a)) &&
+ path[1] === ':' &&
+ (path[2] === '/' || path[2] === '\\'))
+ const normalized = !path.split(/[\\/]/).some((c) => c === '.' || c === '..')
+ return absolute && normalized && (path.endsWith('.go') || path.endsWith('.s'))
+}
+
+/** `filter_go_toolchain_sources`. */
+export function filterGoToolchainSources(paths: string[]): string[] {
+ const norm = (p: string): string => p.replaceAll('\\', '/')
+ const set = new Set(paths.map(norm))
+ const roots: string[] = []
+ for (const p of set) {
+ const i = p.indexOf('/src/runtime/proc.go')
+ if (i < 0) {
+ continue
+ }
+ const root = p.slice(0, i + '/src/'.length)
+ if (GOROOT_WITNESSES.every((w) => set.has(root + w))) {
+ roots.push(root)
+ }
+ }
+ return paths.filter((p) => {
+ const n = norm(p)
+ return !n.includes('/pkg/mod/') && !roots.some((r) => n.startsWith(r))
+ })
+}
+
+/** Rust `String` ordering: byte-wise UTF-8, which equals code-point order. */
+function cmpCodePoints(a: string, b: string): number {
+ let i = 0
+ let j = 0
+ while (i < a.length && j < b.length) {
+ const x = a.codePointAt(i)!
+ const y = b.codePointAt(j)!
+ if (x !== y) {
+ return x - y
+ }
+ i += x > 0xffff ? 2 : 1
+ j += y > 0xffff ? 2 : 1
+ }
+ return a.length - i - (b.length - j)
+}
+
+/** `extract_source_paths_from_dwarf_bytes`. Throws where the Rust function returns `Err`. */
+export function extractSourcePaths(src: Source, opts: { fat64?: boolean } = {}): string[] {
+ const paths = new Set<string>()
+ let anyGo = false
+ for (const obj of openArchive(src, opts)) {
+ const cu = cuMainFiles(obj)
+ anyGo ||= cu.hasGo
+ const prefix = longestCommonPrefix(cu.mainFiles)
+ sessionFiles(obj, (abs) => {
+ if (abs === '') {
+ return
+ }
+ let keep: boolean
+ if (prefix !== null) {
+ keep = abs.startsWith(prefix) || (cu.hasGo && isBundleableGoSource(abs))
+ } else if (cu.hasGo) {
+ keep = isBundleableGoSource(abs)
+ } else {
+ keep = true
+ }
+ if (keep) {
+ paths.add(abs)
+ }
+ })
+ }
+ let out = [...paths].sort(cmpCodePoints)
+ if (anyGo) {
+ out = filterGoToolchainSources(out)
+ }
+ return out
+}
+
+/** `filter_source_paths` (dSYM upload path). */
+export function filterSourcePaths(paths: string[]): string[] {
+ return paths.filter((p) => {
+ const isGo = p.endsWith('.go') || p.endsWith('.s')
+ if (!isGo && EXCLUDED_PREFIXES.some((x) => p.startsWith(x))) {
+ return false
+ }
+ if (EXCLUDED_SUBSTRINGS.some((x) => p.includes(x))) {
+ return false
+ }
+ if (EXCLUDED_SYNTHETIC_NAMES.some((x) => p.startsWith(x))) {
+ return false
+ }
+ return true
+ })
+}
+
+/** `filter_native_source_paths` (ELF and Mach-O symbol sets). */
+export function filterNativeSourcePaths(paths: string[]): string[] {
+ return filterSourcePaths(paths).filter((p) => !NATIVE_EXCLUDED.some((x) => p.includes(x)))
+}
diff --git a/hog/src/error-tracking/run.ts b/hog/src/error-tracking/run.ts
index 51e73b2a5b55..dbea4818e623 100644
--- a/hog/src/error-tracking/run.ts
+++ b/hog/src/error-tracking/run.ts
@@ -41,6 +41,7 @@ import {
type NativeFile,
type NativeProblem,
} from './native/package'
+import { sourceStep } from './native/sources'
import { fetchOrCreateRelease, resolveRelease, type Release, type ReleaseFields } from './release'
import { SymbolSetClient, type SymbolSetUpload, type UploadStatus } from './upload'
@@ -56,6 +57,7 @@ export interface ErrorTrackingOptions {
batchSize?: number
concurrency: number
deleteAfter: boolean
+ includeSource: boolean
dryRun: boolean
}
@@ -472,7 +474,7 @@ export async function upload(
)
if (nativeArtifacts.length > 0) {
const before = skipped.length
- const native = packageNative(nativeArtifacts, selection.cwd, skipped)
+ const native = packageNative(nativeArtifacts, selection.cwd, options.includeSource, skipped, warnings)
if (native.length === 0 && planned.length === 0) {
const details = skipped
.slice(before)
@@ -503,8 +505,9 @@ export async function upload(
reported.id = releaseId
}
}
+ // posthog-cli forces source bundles, because the files on disk change between runs of one build.
const policy = {
- force: options.force,
+ force: options.force || (options.includeSource && !options.skipOnConflict),
skipOnConflict: options.skipOnConflict,
batchSize: options.batchSize ?? 10,
}
@@ -691,12 +694,28 @@ const NATIVE_PROBLEMS: Record<NativeProblem, string> = {
"its DWARF is compressed (`__zdebug` sections), which PostHog can't read yet. Go needs `-ldflags=-compressdwarf=false` on macOS.",
}
+// A path the DWARF names can reach the source folder through a symlink, or the folder can be one,
+// so the globs match the path as written and its canonical form, and either one ignores it.
+function sourceIgnored(root: Root, folder: string): (path: string) => boolean {
+ const canonical = (path: string): string => {
+ try {
+ return realpathSync(path)
+ } catch {
+ return path
+ }
+ }
+ const realFolder = canonical(folder)
+ return (path) => isIgnored(root, folder, path) || isIgnored(root, realFolder, canonical(path))
+}
+
// `symbol-sets upload`: native files are parsed and deduplicated by debug ID, dSYM bundles are
// split per slice, and a dSYM wins over a native file with the same ID.
function packageNative(
artifacts: Artifact[],
cwd: string,
- skipped: Skip[]
+ includeSource: boolean,
+ skipped: Skip[],
+ warnings: string[]
): { artifact: Artifact; upload: SymbolSetUpload }[] {
const owners = new Map<SymbolSetUpload, Artifact>()
const files: { file: NativeFile; artifact: Artifact }[] = []
@@ -725,16 +744,32 @@ function packageNative(
reason: `${byFile.get(kept)!.display} has the same debug ID and is at least as large, so hog uploads that one.`,
})
).map((file) => {
- const upload = nativeUpload(file)
+ const { root } = byFile.get(file)!
+ const folder = resolve(cwd, root.path)
+ const sources = includeSource
+ ? sourceStep(file.data, 'native', warnings, sourceIgnored(root, folder))
+ : undefined
+ const upload = nativeUpload(file, sources)
owners.set(upload, byFile.get(file)!)
return upload
})
const dsyms: SymbolSetUpload[] = []
for (const artifact of artifacts.filter((candidate) => isDsymBundle(candidate.path))) {
try {
+ // Sources come from the whole binary, so every slice of a fat binary carries all of them.
+ const steps = new Map<string, ReturnType<typeof sourceStep>>()
const folder = resolve(cwd, artifact.root.path)
- for (const slice of dsymSlices(artifact.path, (member) => !isIgnored(artifact.root, folder, member))) {
- const upload = dsymUpload(slice)
+ const slices = dsymSlices(artifact.path, (member) => !isIgnored(artifact.root, folder, member))
+ const uploads = slices.map((slice) => {
+ if (includeSource && !steps.has(slice.path)) {
+ steps.set(
+ slice.path,
+ sourceStep(slice.file, 'dsym', warnings, sourceIgnored(artifact.root, folder))
+ )
+ }
+ return dsymUpload(slice, steps.get(slice.path))
+ })
+ for (const upload of uploads) {
owners.set(upload, artifact)
dsyms.push(upload)
}
diff --git a/hog/test/parity/README.md b/hog/test/parity/README.md
index 1ef87d8e8f7e..89a842e0ed19 100644
--- a/hog/test/parity/README.md
+++ b/hog/test/parity/README.md
@@ -27,6 +27,7 @@ The symbol-set upload scenarios then start from the files posthog-cli wrote in t
Native scenarios compare `hog error-tracking upload` with `posthog-cli symbol-sets upload`, which takes ELF files, Mach-O files and dSYM bundles from one folder.
`native/build.sh` builds the binaries from the small C files in `native/src/` with Xcode's clang and ld.lld. Their DWARF records `/tmp/hog-parity-native` as the build folder.
The fixtures cover a fat dSYM, loose Mach-O DWARF files, files without debug info or a build ID, and two files that share a build ID.
+The `--include-source` scenarios put `native/src/` back in that folder first with the `setup` hook, and one scenario leaves it empty to cover sources that can't be read.
Hermes scenarios run the React Native steps in order with `before`: inject the Metro bundle, clone into the composed map, then upload.
The files in `hermes-fixtures.ts` are hand-written, with the Metro and Hermes keys, odd numbers and escapes that the serializer has to reproduce.
diff --git a/hog/test/parity/golden/e2e/native-sources-apple.json b/hog/test/parity/golden/e2e/native-sources-apple.json
new file mode 100644
index 000000000000..1d8043272e37
--- /dev/null
+++ b/hog/test/parity/golden/e2e/native-sources-apple.json
@@ -0,0 +1,90 @@
+{
+ "exitCode": 0,
+ "requests": [
+ {
+ "method": "GET",
+ "path": "/api/projects/1/error_tracking/releases/hash/2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "status": 404
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/releases",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"hash_id\":\"2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45\",\"version\":\"3.2.0\",\"project\":\"shop\"}",
+ "status": 201
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_check_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"323D87C5-2905-3FEF-9169-2E28016F6EA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5\",\"content_length\":1280},{\"chunk_id\":\"8FCB60C2-B0D7-3006-B807-B2CFF36F7CA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82\",\"content_length\":1325},{\"chunk_id\":\"98EFEF90-68BF-3A75-A89C-A388EDB05326\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"44daa7703efe3d2ce4185c6bd2de41b11ce0f45e43f7c24c5cf38ecad8db1f07a842d69dc51d3ad3bc4545743f72479337b41072f51c408a57211db01b31dac6\",\"content_length\":2026}],\"force\":true,\"skip_on_conflict\":false}",
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_start_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"323D87C5-2905-3FEF-9169-2E28016F6EA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5\",\"content_length\":1280},{\"chunk_id\":\"8FCB60C2-B0D7-3006-B807-B2CFF36F7CA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82\",\"content_length\":1325},{\"chunk_id\":\"98EFEF90-68BF-3A75-A89C-A388EDB05326\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"44daa7703efe3d2ce4185c6bd2de41b11ce0f45e43f7c24c5cf38ecad8db1f07a842d69dc51d3ad3bc4545743f72479337b41072f51c408a57211db01b31dac6\",\"content_length\":2026}],\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\",\"force\":true,\"skip_on_conflict\":false}",
+ "status": 201
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/03b8a617-624e-57ff-a78a-fdee042e40a2?length=2026",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "44daa7703efe3d2ce4185c6bd2de41b11ce0f45e43f7c24c5cf38ecad8db1f07a842d69dc51d3ad3bc4545743f72479337b41072f51c408a57211db01b31dac6",
+ "length": 2026
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/cb16c86e-05e6-5f21-af34-941756fc1ad7?length=1280",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5",
+ "length": 1280
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/f7fc99bc-8eab-5b64-b76f-5c19ac73fbcb?length=1325",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82",
+ "length": 1325
+ },
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_finish_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"content_hashes\":{\"03b8a617-624e-57ff-a78a-fdee042e40a2\":\"44daa7703efe3d2ce4185c6bd2de41b11ce0f45e43f7c24c5cf38ecad8db1f07a842d69dc51d3ad3bc4545743f72479337b41072f51c408a57211db01b31dac6\",\"cb16c86e-05e6-5f21-af34-941756fc1ad7\":\"d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5\",\"f7fc99bc-8eab-5b64-b76f-5c19ac73fbcb\":\"331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82\"},\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\"}",
+ "status": 201
+ }
+ ]
+}
diff --git a/hog/test/parity/golden/e2e/native-sources-linux.json b/hog/test/parity/golden/e2e/native-sources-linux.json
new file mode 100644
index 000000000000..b9aa420ca80d
--- /dev/null
+++ b/hog/test/parity/golden/e2e/native-sources-linux.json
@@ -0,0 +1,90 @@
+{
+ "exitCode": 0,
+ "requests": [
+ {
+ "method": "GET",
+ "path": "/api/projects/1/error_tracking/releases/hash/2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "status": 404
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/releases",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"hash_id\":\"2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45\",\"version\":\"3.2.0\",\"project\":\"shop\"}",
+ "status": 201
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_check_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"0ce25816-6d4b-ac9f-e80f-343ac1673748\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"f0de1e261ddc9372e95eac1439e9687744a20356cbe0a3069b5096e1d39892a2ca7f371b475c684f7ce8a930a4c974d7f3e5f5b8f559a021780dc0a9673de4ce\",\"content_length\":1963},{\"chunk_id\":\"33221100-5544-7766-8899-aabbccddeeff\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"ed6a8d152d89e28e5b64494f4decf3db44aa73ba573d0f4af025790d824520f729d015e47d535d957671b728cec5c2a96d8c717953a63bcdaeb3df98b2eb1a07\",\"content_length\":1983},{\"chunk_id\":\"b9297132-c61d-75d5-a1c6-6d01a0cad336\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"13139e488ffb0ccf97550f9a0c9ebd35cef6808809ef9e43444bca0a7374c050cfb350d4a7056b8ac937e9175e3f21e0e421c91d42c45f4ad6a2331f514bb367\",\"content_length\":1501}],\"force\":true,\"skip_on_conflict\":false}",
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_start_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"0ce25816-6d4b-ac9f-e80f-343ac1673748\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"f0de1e261ddc9372e95eac1439e9687744a20356cbe0a3069b5096e1d39892a2ca7f371b475c684f7ce8a930a4c974d7f3e5f5b8f559a021780dc0a9673de4ce\",\"content_length\":1963},{\"chunk_id\":\"33221100-5544-7766-8899-aabbccddeeff\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"ed6a8d152d89e28e5b64494f4decf3db44aa73ba573d0f4af025790d824520f729d015e47d535d957671b728cec5c2a96d8c717953a63bcdaeb3df98b2eb1a07\",\"content_length\":1983},{\"chunk_id\":\"b9297132-c61d-75d5-a1c6-6d01a0cad336\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"13139e488ffb0ccf97550f9a0c9ebd35cef6808809ef9e43444bca0a7374c050cfb350d4a7056b8ac937e9175e3f21e0e421c91d42c45f4ad6a2331f514bb367\",\"content_length\":1501}],\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\",\"force\":true,\"skip_on_conflict\":false}",
+ "status": 201
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/95b7661b-fb89-53c4-bdcb-bc1a62f7aebe?length=1963",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "f0de1e261ddc9372e95eac1439e9687744a20356cbe0a3069b5096e1d39892a2ca7f371b475c684f7ce8a930a4c974d7f3e5f5b8f559a021780dc0a9673de4ce",
+ "length": 1963
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/9df6ea99-d371-5ad2-83f1-9ce9293c58c2?length=1501",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "13139e488ffb0ccf97550f9a0c9ebd35cef6808809ef9e43444bca0a7374c050cfb350d4a7056b8ac937e9175e3f21e0e421c91d42c45f4ad6a2331f514bb367",
+ "length": 1501
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/fcc4e959-0957-51c0-887f-2b286c2fbca3?length=1983",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "ed6a8d152d89e28e5b64494f4decf3db44aa73ba573d0f4af025790d824520f729d015e47d535d957671b728cec5c2a96d8c717953a63bcdaeb3df98b2eb1a07",
+ "length": 1983
+ },
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_finish_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"content_hashes\":{\"95b7661b-fb89-53c4-bdcb-bc1a62f7aebe\":\"f0de1e261ddc9372e95eac1439e9687744a20356cbe0a3069b5096e1d39892a2ca7f371b475c684f7ce8a930a4c974d7f3e5f5b8f559a021780dc0a9673de4ce\",\"9df6ea99-d371-5ad2-83f1-9ce9293c58c2\":\"13139e488ffb0ccf97550f9a0c9ebd35cef6808809ef9e43444bca0a7374c050cfb350d4a7056b8ac937e9175e3f21e0e421c91d42c45f4ad6a2331f514bb367\",\"fcc4e959-0957-51c0-887f-2b286c2fbca3\":\"ed6a8d152d89e28e5b64494f4decf3db44aa73ba573d0f4af025790d824520f729d015e47d535d957671b728cec5c2a96d8c717953a63bcdaeb3df98b2eb1a07\"},\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\"}",
+ "status": 201
+ }
+ ]
+}
diff --git a/hog/test/parity/golden/e2e/native-sources-loose.json b/hog/test/parity/golden/e2e/native-sources-loose.json
new file mode 100644
index 000000000000..9605c703c447
--- /dev/null
+++ b/hog/test/parity/golden/e2e/native-sources-loose.json
@@ -0,0 +1,78 @@
+{
+ "exitCode": 0,
+ "requests": [
+ {
+ "method": "GET",
+ "path": "/api/projects/1/error_tracking/releases/hash/2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "status": 404
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/releases",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"hash_id\":\"2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45\",\"version\":\"3.2.0\",\"project\":\"shop\"}",
+ "status": 201
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_check_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"323D87C5-2905-3FEF-9169-2E28016F6EA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5\",\"content_length\":1280},{\"chunk_id\":\"8FCB60C2-B0D7-3006-B807-B2CFF36F7CA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82\",\"content_length\":1325}],\"force\":true,\"skip_on_conflict\":false}",
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_start_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"323D87C5-2905-3FEF-9169-2E28016F6EA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5\",\"content_length\":1280},{\"chunk_id\":\"8FCB60C2-B0D7-3006-B807-B2CFF36F7CA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82\",\"content_length\":1325}],\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\",\"force\":true,\"skip_on_conflict\":false}",
+ "status": 201
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/cb16c86e-05e6-5f21-af34-941756fc1ad7?length=1280",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5",
+ "length": 1280
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/f7fc99bc-8eab-5b64-b76f-5c19ac73fbcb?length=1325",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82",
+ "length": 1325
+ },
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_finish_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"content_hashes\":{\"cb16c86e-05e6-5f21-af34-941756fc1ad7\":\"d16444357eda24eda52d3776366a99943cc52ba6e5dcf05404a802c3328ea3bef59f24ebc80c026b39977b9ed79e00efe4623b66275cca9519d0648ed9bcb0d5\",\"f7fc99bc-8eab-5b64-b76f-5c19ac73fbcb\":\"331a37c769b33bf525e7460468e2991eff36aba81e2a366e63b4da5ebc1dcd96f3862361764d5e5d017dbce705463cb0a698f4a24df938e8d9213646ab27ce82\"},\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\"}",
+ "status": 201
+ }
+ ]
+}
diff --git a/hog/test/parity/golden/e2e/native-sources-missing.json b/hog/test/parity/golden/e2e/native-sources-missing.json
new file mode 100644
index 000000000000..5e2f616e41f2
--- /dev/null
+++ b/hog/test/parity/golden/e2e/native-sources-missing.json
@@ -0,0 +1,126 @@
+{
+ "exitCode": 0,
+ "requests": [
+ {
+ "method": "GET",
+ "path": "/api/projects/1/error_tracking/releases/hash/2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "status": 404
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/releases",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"hash_id\":\"2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45\",\"version\":\"3.2.0\",\"project\":\"shop\"}",
+ "status": 201
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_check_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"0ce25816-6d4b-ac9f-e80f-343ac1673748\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"4bbe6b9466f41dd70534ac38b8c4180e0b76387e423520d40f34b884050c0ecfef162b4da54626834410530d5eda25ca862096bf03dcb8d5f0128c7fafff4056\",\"content_length\":1576},{\"chunk_id\":\"323D87C5-2905-3FEF-9169-2E28016F6EA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"da2af7cf461069dbf4ef4f24398a5a26fba3fda9fd518d99b0b34142c0b55662b27f2bfb9e85ed64b78532b198911cdd8844deeb74fbd31b0e8de6e03e2edd2f\",\"content_length\":1087},{\"chunk_id\":\"33221100-5544-7766-8899-aabbccddeeff\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"eeac2469474597c7b5c187478a61a757b4e504ad8c8d69b21158853c3b2ff5fd8518ee99602c61b3ed6a91e7ef3c49f5173c3666eeba0083e97841f4d7af6758\",\"content_length\":1593},{\"chunk_id\":\"8FCB60C2-B0D7-3006-B807-B2CFF36F7CA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"795d7c2e67604d48332beed1cd75e9ba0008bc5320a38b43c1e2b0cb2343947319f09b382fc19a3490bcb804361e20e754abeddfe467d267a420fe51657d40ab\",\"content_length\":1131},{\"chunk_id\":\"98EFEF90-68BF-3A75-A89C-A388EDB05326\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"5dcbb53d7279c3d4304903452814d9422f9c1b3290353b5baafe6029b61af858c145220ca5ecff6b908f2ade9f507f03b182aebceb4f47d1872868ecfc2e0702\",\"content_length\":1520},{\"chunk_id\":\"b9297132-c61d-75d5-a1c6-6d01a0cad336\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"23ccb4fb89e62f48467056ec7673f4fb83f5b590b2e1ba6ca88684765755c7e767437c99f66fee0c75b6f213902bf4be5783cfaff70b23cfadfc51e95f395896\",\"content_length\":1310}],\"force\":true,\"skip_on_conflict\":false}",
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_start_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"0ce25816-6d4b-ac9f-e80f-343ac1673748\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"4bbe6b9466f41dd70534ac38b8c4180e0b76387e423520d40f34b884050c0ecfef162b4da54626834410530d5eda25ca862096bf03dcb8d5f0128c7fafff4056\",\"content_length\":1576},{\"chunk_id\":\"323D87C5-2905-3FEF-9169-2E28016F6EA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"da2af7cf461069dbf4ef4f24398a5a26fba3fda9fd518d99b0b34142c0b55662b27f2bfb9e85ed64b78532b198911cdd8844deeb74fbd31b0e8de6e03e2edd2f\",\"content_length\":1087},{\"chunk_id\":\"33221100-5544-7766-8899-aabbccddeeff\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"eeac2469474597c7b5c187478a61a757b4e504ad8c8d69b21158853c3b2ff5fd8518ee99602c61b3ed6a91e7ef3c49f5173c3666eeba0083e97841f4d7af6758\",\"content_length\":1593},{\"chunk_id\":\"8FCB60C2-B0D7-3006-B807-B2CFF36F7CA3\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"795d7c2e67604d48332beed1cd75e9ba0008bc5320a38b43c1e2b0cb2343947319f09b382fc19a3490bcb804361e20e754abeddfe467d267a420fe51657d40ab\",\"content_length\":1131},{\"chunk_id\":\"98EFEF90-68BF-3A75-A89C-A388EDB05326\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"5dcbb53d7279c3d4304903452814d9422f9c1b3290353b5baafe6029b61af858c145220ca5ecff6b908f2ade9f507f03b182aebceb4f47d1872868ecfc2e0702\",\"content_length\":1520},{\"chunk_id\":\"b9297132-c61d-75d5-a1c6-6d01a0cad336\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"23ccb4fb89e62f48467056ec7673f4fb83f5b590b2e1ba6ca88684765755c7e767437c99f66fee0c75b6f213902bf4be5783cfaff70b23cfadfc51e95f395896\",\"content_length\":1310}],\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\",\"force\":true,\"skip_on_conflict\":false}",
+ "status": 201
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/03b8a617-624e-57ff-a78a-fdee042e40a2?length=1520",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "5dcbb53d7279c3d4304903452814d9422f9c1b3290353b5baafe6029b61af858c145220ca5ecff6b908f2ade9f507f03b182aebceb4f47d1872868ecfc2e0702",
+ "length": 1520
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/95b7661b-fb89-53c4-bdcb-bc1a62f7aebe?length=1576",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "4bbe6b9466f41dd70534ac38b8c4180e0b76387e423520d40f34b884050c0ecfef162b4da54626834410530d5eda25ca862096bf03dcb8d5f0128c7fafff4056",
+ "length": 1576
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/9df6ea99-d371-5ad2-83f1-9ce9293c58c2?length=1310",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "23ccb4fb89e62f48467056ec7673f4fb83f5b590b2e1ba6ca88684765755c7e767437c99f66fee0c75b6f213902bf4be5783cfaff70b23cfadfc51e95f395896",
+ "length": 1310
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/cb16c86e-05e6-5f21-af34-941756fc1ad7?length=1087",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "da2af7cf461069dbf4ef4f24398a5a26fba3fda9fd518d99b0b34142c0b55662b27f2bfb9e85ed64b78532b198911cdd8844deeb74fbd31b0e8de6e03e2edd2f",
+ "length": 1087
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/f7fc99bc-8eab-5b64-b76f-5c19ac73fbcb?length=1131",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "795d7c2e67604d48332beed1cd75e9ba0008bc5320a38b43c1e2b0cb2343947319f09b382fc19a3490bcb804361e20e754abeddfe467d267a420fe51657d40ab",
+ "length": 1131
+ },
+ "status": 200
+ },
+ {
+ "method": "PUT",
+ "path": "/s3/put/symbolsets/fcc4e959-0957-51c0-887f-2b286c2fbca3?length=1593",
+ "headers": {
+ "authorization": "<none>"
+ },
+ "upload": {
+ "sha512": "eeac2469474597c7b5c187478a61a757b4e504ad8c8d69b21158853c3b2ff5fd8518ee99602c61b3ed6a91e7ef3c49f5173c3666eeba0083e97841f4d7af6758",
+ "length": 1593
+ },
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_finish_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"content_hashes\":{\"03b8a617-624e-57ff-a78a-fdee042e40a2\":\"5dcbb53d7279c3d4304903452814d9422f9c1b3290353b5baafe6029b61af858c145220ca5ecff6b908f2ade9f507f03b182aebceb4f47d1872868ecfc2e0702\",\"95b7661b-fb89-53c4-bdcb-bc1a62f7aebe\":\"4bbe6b9466f41dd70534ac38b8c4180e0b76387e423520d40f34b884050c0ecfef162b4da54626834410530d5eda25ca862096bf03dcb8d5f0128c7fafff4056\",\"9df6ea99-d371-5ad2-83f1-9ce9293c58c2\":\"23ccb4fb89e62f48467056ec7673f4fb83f5b590b2e1ba6ca88684765755c7e767437c99f66fee0c75b6f213902bf4be5783cfaff70b23cfadfc51e95f395896\",\"cb16c86e-05e6-5f21-af34-941756fc1ad7\":\"da2af7cf461069dbf4ef4f24398a5a26fba3fda9fd518d99b0b34142c0b55662b27f2bfb9e85ed64b78532b198911cdd8844deeb74fbd31b0e8de6e03e2edd2f\",\"f7fc99bc-8eab-5b64-b76f-5c19ac73fbcb\":\"795d7c2e67604d48332beed1cd75e9ba0008bc5320a38b43c1e2b0cb2343947319f09b382fc19a3490bcb804361e20e754abeddfe467d267a420fe51657d40ab\",\"fcc4e959-0957-51c0-887f-2b286c2fbca3\":\"eeac2469474597c7b5c187478a61a757b4e504ad8c8d69b21158853c3b2ff5fd8518ee99602c61b3ed6a91e7ef3c49f5173c3666eeba0083e97841f4d7af6758\"},\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\"}",
+ "status": 201
+ }
+ ]
+}
diff --git a/hog/test/parity/golden/e2e/native-sources-skip-on-conflict.json b/hog/test/parity/golden/e2e/native-sources-skip-on-conflict.json
new file mode 100644
index 000000000000..fbce494f71c3
--- /dev/null
+++ b/hog/test/parity/golden/e2e/native-sources-skip-on-conflict.json
@@ -0,0 +1,44 @@
+{
+ "exitCode": 0,
+ "requests": [
+ {
+ "method": "GET",
+ "path": "/api/projects/1/error_tracking/releases/hash/2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "status": 404
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/releases",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"hash_id\":\"2fe445ce7d3dbca51f8170eff7d191a77579d1d0e6702eaf0485b1ffb4377bf11ed333df66d045aafd8c38d6aec52123fe7757f0a73d46fdf09d3f2966de5f45\",\"version\":\"3.2.0\",\"project\":\"shop\"}",
+ "status": 201
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_check_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"0ce25816-6d4b-ac9f-e80f-343ac1673748\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"f0de1e261ddc9372e95eac1439e9687744a20356cbe0a3069b5096e1d39892a2ca7f371b475c684f7ce8a930a4c974d7f3e5f5b8f559a021780dc0a9673de4ce\",\"content_length\":1963},{\"chunk_id\":\"33221100-5544-7766-8899-aabbccddeeff\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"ed6a8d152d89e28e5b64494f4decf3db44aa73ba573d0f4af025790d824520f729d015e47d535d957671b728cec5c2a96d8c717953a63bcdaeb3df98b2eb1a07\",\"content_length\":1983},{\"chunk_id\":\"b9297132-c61d-75d5-a1c6-6d01a0cad336\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"13139e488ffb0ccf97550f9a0c9ebd35cef6808809ef9e43444bca0a7374c050cfb350d4a7056b8ac937e9175e3f21e0e421c91d42c45f4ad6a2331f514bb367\",\"content_length\":1501}],\"force\":false,\"skip_on_conflict\":true}",
+ "status": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/projects/1/error_tracking/symbol_sets/bulk_start_upload",
+ "headers": {
+ "authorization": "Bearer phx_<key>",
+ "content-type": "application/json"
+ },
+ "body": "{\"symbol_sets\":[{\"chunk_id\":\"0ce25816-6d4b-ac9f-e80f-343ac1673748\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"f0de1e261ddc9372e95eac1439e9687744a20356cbe0a3069b5096e1d39892a2ca7f371b475c684f7ce8a930a4c974d7f3e5f5b8f559a021780dc0a9673de4ce\",\"content_length\":1963},{\"chunk_id\":\"33221100-5544-7766-8899-aabbccddeeff\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"ed6a8d152d89e28e5b64494f4decf3db44aa73ba573d0f4af025790d824520f729d015e47d535d957671b728cec5c2a96d8c717953a63bcdaeb3df98b2eb1a07\",\"content_length\":1983},{\"chunk_id\":\"b9297132-c61d-75d5-a1c6-6d01a0cad336\",\"release_id\":\"a3614f5f-44e8-5368-b5a4-7de9e0b00620\",\"content_hash\":\"13139e488ffb0ccf97550f9a0c9ebd35cef6808809ef9e43444bca0a7374c050cfb350d4a7056b8ac937e9175e3f21e0e421c91d42c45f4ad6a2331f514bb367\",\"content_length\":1501}],\"upload_attempt_id\":\"<attempt-1>\",\"upload_run_id\":\"<run>\",\"force\":false,\"skip_on_conflict\":true}",
+ "status": 201
+ }
+ ]
+}
diff --git a/hog/test/parity/run.ts b/hog/test/parity/run.ts
index a569de1e96ba..1056c7fa59b7 100644
--- a/hog/test/parity/run.ts
+++ b/hog/test/parity/run.ts
@@ -93,6 +93,7 @@ export async function runScenario(scenario: ParityScenario, cli: { rust: string
const folder = mkdtempSync(join(tmpdir(), 'hog-parity-'))
const home = mkdtempSync(join(tmpdir(), 'hog-parity-home-'))
write(folder, scenario.files())
+ scenario.setup?.()
const server = startFakeServer(scenario.server)
try {
const env = environment(server.url, home)
diff --git a/hog/test/parity/scenarios.ts b/hog/test/parity/scenarios.ts
index adfbf138b805..3fa31a4d4546 100644
--- a/hog/test/parity/scenarios.ts
+++ b/hog/test/parity/scenarios.ts
@@ -1,8 +1,8 @@
-import { readFileSync } from 'node:fs'
+import { readFileSync, rmSync } from 'node:fs'
import { join } from 'node:path'
import type { Scenario } from './fake-server'
-import { GIT_REPO, mappingOfSize, readTree, SMALL_MAPPING } from './fixtures'
+import { GIT_REPO, mappingOfSize, readTree, SMALL_MAPPING, write } from './fixtures'
import { EXPO_BUILD, HERMES_BUILD, HERMES_BUNDLES } from './hermes-fixtures'
import { bundles, EDGE_CASES, MALFORMED_MAP_DEBUG_ID, PUBLIC_PATH, STYLESHEET_LOOKUP, STYLESHEETS } from './js-fixtures'
import { decodeFile, type ParityResult } from './run'
@@ -23,6 +23,8 @@ export interface ParityScenario {
snapshot?: boolean
// The run mints random UUIDv7 chunk ids, so compare their positions and not their values.
randomIds?: boolean
+ // Runs before the commands, for state outside the folder.
+ setup?: () => void
}
// The files posthog-cli left behind in another scenario, so a step can start from its real output.
@@ -282,3 +284,24 @@ SCENARIOS.push(
native('release-mismatch', 'apple', apple, { args: nativeRelease, server: 'release-mismatch' }),
native('only-unusable', 'linux/checkout-no-build-id', linux)
)
+
+// The native fixtures' DWARF names sources under this folder, which `--include-source` reads.
+const NATIVE_SOURCES = '/tmp/hog-parity-native'
+const placeSources = (): void => {
+ rmSync(NATIVE_SOURCES, { recursive: true, force: true })
+ write(NATIVE_SOURCES, readTree(join(import.meta.dir, 'native', 'src')))
+}
+const removeSources = (): void => rmSync(NATIVE_SOURCES, { recursive: true, force: true })
+const withSources = ['--include-source', ...nativeRelease]
+
+SCENARIOS.push(
+ native('sources-linux', 'linux', linux, { args: withSources, setup: placeSources }),
+ native('sources-apple', 'apple', apple, { args: withSources, setup: placeSources }),
+ native('sources-loose', 'apple-loose', appleLoose, { args: withSources, setup: placeSources }),
+ native('sources-skip-on-conflict', 'linux', linux, {
+ args: [...withSources, '--skip-on-conflict'],
+ server: 'hash-mismatch',
+ setup: placeSources,
+ }),
+ native('sources-missing', '.', () => ({ ...linux(), ...apple() }), { args: withSources, setup: removeSources })
+)