{"record":{"id":"1c42dadbf8eaf99f","repo":"Hmbown/CodeWhale","slug":"codewhale-session-produced-no-inspectable-events-pet-native","errorCode":null,"errorMessage":"Codewhale session produced no inspectable events.","messagePattern":"Codewhale session produced no inspectable events\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/ios/Resources/pet-native.js","lineNumber":2151,"sourceCode":"            else {\n                const text = str(block.text) ?? '';\n                const operate = text.includes('codewhale:runtime_event');\n                const user = role === 'user' || role === 'User';\n                pushEvent(events, {\n                    schemaVersion: 1, id: idBase, traceId: sessionId, parentId: parentEventId,\n                    startTime: t.start, endTime: t.start, agentId,\n                    name: operate ? 'operate_contract' : user ? 'user_message' : 'assistant_message',\n                    category: operate ? 'orchestration' : user ? 'human' : 'communication',\n                    model, provider, status: 'success',\n                    attributes: { 'codewhale.entry_id': entryId, 'codewhale.seq': seq, role: role ?? 'unknown' },\n                    payload: { text: clip(text) }, raw,\n                });\n            }\n            seq += 1;\n        }\n    }\n    if (!events.length)\n        throw new Error('Codewhale session produced no inspectable events.');\n    for (const event of events) {\n        if (event.openEnded && event.tool)\n            warnings.push(`Tool ${event.id} has no matching tool_result in this snapshot; duration remains unknown.`);\n    }\n    const base = events.reduce((m, e) => Math.min(m, e.startTime), events[0].startTime);\n    for (const event of events) {\n        event.startTime -= base;\n        event.endTime -= base;\n    }\n    const cost = obj(metadata.cost);\n    const sessionCost = num(cost.session_cost_usd);\n    const duration = Math.max(1, events.reduce((m, e) => Math.max(m, e.endTime, e.startTime), 0));\n    const uniqueWarnings = [...new Set(warnings)];\n    return {\n        id: sessionId,\n        name: titleOfSession(metadata, filename),\n        events,\n        duration,","sourceCodeStart":2133,"sourceCodeEnd":2169,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/ios/Resources/pet-native.js#L2133-L2169","documentation":"Thrown after parsing a Codewhale session snapshot when the events array ends up empty. The importer requires at least one inspectable event to build a timeline; an import that would produce zero events is treated as invalid input rather than an empty result. It prevents the subsequent timeline base computation (events[0]) from failing on an empty array.","triggerScenarios":"Running the session importer on a snapshot whose entries are all skipped: entries with no usable message content, no recognized role, no text, or no parseable timestamps, so no event is ever pushed before the !events.length check at pet/ios/Resources/pet-native.js:2151.","commonSituations":"Exporting a session that only contains tool-call metadata without message content; a truncated or corrupt export file; a version change in Codewhale's snapshot format so the parser no longer recognizes entries; passing the wrong file (e.g. a config or log file) to the importer.","solutions":["Verify the snapshot file actually contains message/item entries with content or text.","Re-export the Codewhale session and confirm the export is non-empty and complete.","Check the parser still matches your Codewhale version's snapshot schema; update the exporter/importer pair together.","Inspect a few entries with the same parsing helpers (str/obj) to see why they are rejected."],"exampleFix":"// before\nconst events = importCodewhaleSession(readFile(path));\n// after\nconst raw = JSON.parse(readFile(path));\nif (!raw.entries?.some(e => e.message?.content?.length || e.text)) {\n  throw new Error('Snapshot has no inspectable entries; re-export the session.');\n}\nconst events = importCodewhaleSession(raw);","handlingStrategy":"validation","validationCode":"const entries = snapshot.entries ?? [];\nconst inspectable = entries.some(e => (e.message?.content?.length ?? 0) > 0 || e.text || e.message?.text);\nif (!inspectable) throw new Error('Snapshot has no inspectable entries; re-export before importing.');","typeGuard":"function hasInspectableEntries(snapshot) {\n  return Array.isArray(snapshot?.entries) && snapshot.entries.some(\n    e => e && (typeof e.text === 'string' || typeof e.message?.text === 'string' || Array.isArray(e.message?.content))\n  );\n}","tryCatchPattern":"try {\n  importCodewhaleSession(snapshot);\n} catch (e) {\n  if (String(e.message).includes('no inspectable events')) {\n    console.error('Export appears empty or format-incompatible; re-export the session.');\n  } else throw e;\n}","preventionTips":["Verify exports are non-empty and contain message content before import.","Keep exporter and importer versions in sync.","Check you are passing the session snapshot file, not another JSONL.","Validate one entry parses with your role/text expectations before a full import."],"tags":["import","empty","session"],"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"}