{"record":{"id":"f198a9ef6874bdbc","repo":"Hmbown/CodeWhale","slug":"runtime-import-cancelled-a-line-is-not-a-codewhale-runtime-f198a9","errorCode":null,"errorMessage":"Runtime import cancelled: a line is not a Codewhale runtime event record. No rows were skipped.","messagePattern":"Runtime import cancelled: a line is not a Codewhale runtime event record\\. No rows were skipped\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/ios/Resources/pet-native.js","lineNumber":2310,"sourceCode":"    append(records) {\n        if (!records.length)\n            return;\n        const { events, open, requests } = this;\n        const threadId = this.threadId ?? str(obj(records[0]).thread_id) ?? this.filename;\n        this.threadId = threadId;\n        let { origin, model, skippedDeltas } = this;\n        let threadName = this.threadName ?? threadId;\n        const stamp = (rec) => {\n            const t = parseTime(rec.timestamp);\n            if (t === undefined)\n                throw new Error(`Runtime event seq ${rec.seq} is missing a usable timestamp.`);\n            if (origin === undefined)\n                origin = t;\n            return t - origin;\n        };\n        for (const raw of records) {\n            if (!isCodewhaleRuntimeRecord(raw))\n                throw new Error('Runtime import cancelled: a line is not a Codewhale runtime event record. No rows were skipped.');\n            this.recordCount++;\n            const rec = obj(raw);\n            if (rec.thread_id !== threadId)\n                throw new Error('Runtime import contains multiple threads. Export one thread before importing.');\n            const eventName = rec.event;\n            if (eventName === 'item.delta') {\n                skippedDeltas++;\n                continue;\n            }\n            const payload = obj(rec.payload);\n            const item = obj(payload.item);\n            const turn = obj(payload.turn);\n            const thread = obj(payload.thread);\n            const relative = stamp(rec);\n            const turnId = str(rec.turn_id) ?? str(payload.turn_id);\n            const itemId = str(rec.item_id) ?? str(item.id);\n            const agentId = 'parent';\n            if (str(thread.model))","sourceCodeStart":2292,"sourceCodeEnd":2328,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/ios/Resources/pet-native.js#L2292-L2328","documentation":"Thrown at the start of the runtime record loop when a parsed line fails isCodewhaleRuntimeRecord(), i.e. it does not have the shape of a Codewhale runtime event record. The import is deliberately cancelled with no rows skipped: the library refuses to partially import a file that is not cleanly a runtime export. This protects against importing the wrong file or a corrupted one.","triggerScenarios":"Importing a runtime file where at least one record lacks the required runtime-record shape (missing seq/event/thread fields, wrong types) so isCodewhaleRuntimeRecord(raw) returns false at pet/ios/Resources/pet-native.js:2310. Happens on the first bad line.","commonSituations":"Pointing the importer at the wrong file (session snapshot, logs, or another JSONL); a truncated final line from an interrupted export; hand-merged files mixing record kinds; schema drift after a Codewhale version update.","solutions":["Confirm you are importing a Codewhale runtime export (JSONL of runtime event records), not a session snapshot or other file.","Find and inspect the first invalid line (check for truncated/partial JSON from an interrupted export).","Re-export the thread and re-import the fresh file.","Pre-validate all lines with the same record shape check before feeding the importer."],"exampleFix":"// before\nruntime.feed(threadId, text.split('\\n').map(l => JSON.parse(l)));\n// after\nconst records = text.split('\\n').filter(Boolean).map(l => JSON.parse(l));\nconst bad = records.findIndex(r => !isCodewhaleRuntimeRecord(r));\nif (bad >= 0) throw new Error(`Line ${bad + 1} is not a runtime record`);\nconst events = runtime.feed(threadId, records);","handlingStrategy":"type-guard","validationCode":"const badIndex = records.findIndex(r => !isCodewhaleRuntimeRecord(r));\nif (badIndex >= 0) throw new Error(`Line ${badIndex + 1} is not a Codewhale runtime record; wrong or corrupt file?`);","typeGuard":"function isRuntimeRecordFile(records) {\n  return Array.isArray(records) && records.length > 0 && records.every(isCodewhaleRuntimeRecord);\n}","tryCatchPattern":"try {\n  runtime.import(text, threadId);\n} catch (e) {\n  if (String(e.message).includes('not a Codewhale runtime event record')) {\n    console.error('File rejected wholesale: verify it is a runtime export and not truncated.');\n  } else throw e;\n}","preventionTips":["Confirm the file type before import (runtime export vs session snapshot).","Validate every line's record shape before importing.","Handle truncated last lines from interrupted exports.","Pin importer/exporter versions together."],"tags":["import","validation","format"],"backgroundTag":"schema-validation-failed","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}