{"record":{"id":"cf9d788c45e64293","repo":"Hmbown/CodeWhale","slug":"codewhale-runtime-file-contained-only-stream-deltas-or-pet","errorCode":null,"errorMessage":"Codewhale runtime file contained only stream deltas or unreadable records.","messagePattern":"Codewhale runtime file contained only stream deltas or unreadable records\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/ios/Resources/pet-native.js","lineNumber":2482,"sourceCode":"            });\n        }\n        this.origin = origin;\n        this.model = model;\n        this.threadName = threadName;\n        this.skippedDeltas = skippedDeltas;\n    }\n    snapshot() {\n        const { events, open, requests, origin, model, skippedDeltas, filename } = this;\n        const threadId = this.threadId ?? filename, threadName = this.threadName ?? threadId;\n        const warnings = [];\n        if (skippedDeltas)\n            warnings.push(`Dropped ${skippedDeltas.toLocaleString()} item.delta records; they are token stream fragments, not spans. Item start/end remain the source of duration.`);\n        for (const [id] of open)\n            warnings.push(`Item ${id} started and never completed in this file; duration remains unknown.`);\n        for (const request of requests.values())\n            warnings.push(`Request ${request.id} has no terminal receipt; its duration remains unknown in this file.`);\n        if (!events.length)\n            throw new Error('Codewhale runtime file contained only stream deltas or unreadable records.');\n        const base = events.reduce((m, e) => Math.min(m, e.startTime), events[0].startTime);\n        const normalized = events.map(event => ({ ...event, startTime: event.startTime - base, endTime: event.endTime - base,\n            attributes: { ...event.attributes, ...(event.attributes['whalesong.error_onset_ms'] !== undefined\n                    ? { 'whalesong.error_onset_ms': (0, model_js_1.errorOnsetOf)(event) - base } : {}) } }));\n        return {\n            id: threadId,\n            name: `Codewhale runtime · ${threadName}`,\n            events: normalized,\n            duration: Math.max(1, normalized.reduce((m, e) => Math.max(m, e.endTime, e.startTime, e.status === 'error' ? (0, model_js_1.errorOnsetOf)(e) : 0), 0)),\n            originTime: origin !== undefined ? new Date(origin + base).toISOString() : '0 ms',\n            source: 'codewhale',\n            privacy: 'redact',\n            warnings: [...new Set(warnings)],\n            metadata: {\n                sourceFormat: 'codewhale.runtime-events/v2',\n                timeBasis: 'wall-clock',\n                sourceFilename: filename,\n                threadId,","sourceCodeStart":2464,"sourceCodeEnd":2500,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/ios/Resources/pet-native.js#L2464-L2500","documentation":"Thrown at the end of a runtime import when, after all parsing, no events could be built — the file only contained item.delta stream fragments (which are skipped by design) or unreadable records. Since a timeline needs at least one real start/end pair, an all-deltas file yields nothing importable and is rejected instead of returning an empty timeline. Warnings about dropped deltas are still collected first.","triggerScenarios":"Importing a runtime file whose non-skipped records all failed to become events: e.g. only item.delta records, only turn.lifecycle records, or item start/end records that could not be resolved, so events.length === 0 at the check in pet/ios/Resources/pet-native.js:2482.","commonSituations":"Exporting a thread that never produced any completed items (interrupted immediately); a file of only token-stream deltas; a schema mismatch where start/end records are not recognized; pointing the importer at a delta-only capture stream instead of the full export.","solutions":["Re-export the thread and confirm the export contains item start/end records, not just deltas.","Check the export is complete (not truncated before any item started).","Verify importer and exporter versions match so item records are recognized.","Import a different/earlier snapshot of the thread that includes real item events."],"exampleFix":"// before\nconst events = runtime.import(file, threadId); // may throw on deltas-only file\n// after\nconst records = readRecords(file);\nif (!records.some(r => r.event === 'item.started' || r.event === 'item.completed')) {\n  throw new Error('File has no item start/end records; re-export the thread.');\n}\nconst events = runtime.import(file, threadId);","handlingStrategy":"validation","validationCode":"const hasItems = records.some(r => !r.event?.startsWith('item.delta'));\nif (!hasItems) throw new Error('File contains only item.delta records; nothing to import. Re-export the thread.');","typeGuard":"function hasImportableEvents(records) {\n  return Array.isArray(records) && records.some(r => typeof r?.event === 'string' && !r.event.startsWith('item.delta'));\n}","tryCatchPattern":"try {\n  const result = runtime.import(file, threadId);\n} catch (e) {\n  if (String(e.message).includes('only stream deltas')) {\n    console.error('No importable item events in this file; use a full thread export.');\n  } else throw e;\n}","preventionTips":["Confirm the export includes item start/end records, not only deltas.","Export complete threads (not partial captures) before importing.","Verify schema compatibility between exporter and importer versions.","Check warnings from prior imports: many dropped deltas hint at a deltas-only file."],"tags":["import","empty","deltas"],"backgroundTag":"empty-result-set","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}