{"record":{"id":"428190ae425d4196","repo":"Hmbown/CodeWhale","slug":"runtime-event-seq-rec-seq-is-missing-a-usable-timestamp-pet","errorCode":null,"errorMessage":"Runtime event seq ${rec.seq} is missing a usable timestamp.","messagePattern":"Runtime event seq (.+?) is missing a usable timestamp\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/ios/Resources/pet-native.js","lineNumber":2303,"sourceCode":"                this.sizes.delete(event);\n                if (this.open.get(event.id) === event)\n                    this.open.delete(event.id);\n            }\n        }\n        this.events.length = keep;\n    }\n    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);","sourceCodeStart":2285,"sourceCodeEnd":2321,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/ios/Resources/pet-native.js#L2285-L2321","documentation":"Thrown while converting raw runtime records into events: a record's timestamp could not be parsed into a usable time (parseTime returned undefined), so no relative start time can be computed. Every retained record must be placeable on the timeline; one unreadable timestamp aborts the whole import. The message includes rec.seq to identify the offending record.","triggerScenarios":"Importing a Codewhale runtime file where a record (identified by its seq field) has a missing, malformed, or unsupported timestamp value so parseTime(rec.timestamp) yields undefined at pet/ios/Resources/pet-native.js:2303.","commonSituations":"An export interrupted mid-write leaving a record with an empty timestamp; a timestamp in a format the parser does not recognize (e.g. relative seconds instead of ISO 8601); hand-edited or filtered JSONL files; a version change in the runtime record schema.","solutions":["Inspect the record with the reported seq in the runtime file and fix or restore its timestamp.","Re-export the thread; a complete export should always carry timestamps.","Normalize timestamps to ISO 8601 strings the parser accepts before importing.","Filter out records without a valid timestamp (acknowledging the whole-file abort this error implies) via a pre-parse validation pass."],"exampleFix":"// before\nconst events = runtime.feed(threadId, lines.map(JSON.parse));\n// after\nconst records = lines.map(JSON.parse);\nconst bad = records.find(r => r.timestamp === undefined || Number.isNaN(Date.parse(r.timestamp)));\nif (bad) throw new Error(`Record seq ${bad.seq} has bad timestamp`);\nconst events = runtime.feed(threadId, records);","handlingStrategy":"validation","validationCode":"const bad = records.find(r => r.timestamp === undefined || Number.isNaN(Date.parse(r.timestamp)));\nif (bad) throw new Error(`Record seq ${bad.seq} has unusable timestamp ${JSON.stringify(bad.timestamp)}`);","typeGuard":"function hasUsableTimestamp(rec) {\n  return rec != null && typeof rec.timestamp === 'string' && !Number.isNaN(Date.parse(rec.timestamp));\n}","tryCatchPattern":"try {\n  runtime.import(file, threadId);\n} catch (e) {\n  const m = /seq (\\d+) is missing a usable timestamp/.exec(e.message);\n  if (m) console.error(`Bad timestamp on record seq ${m[1]}; re-export or repair that record.`);\n  else throw e;\n}","preventionTips":["Pre-validate all timestamps (ISO 8601) before feeding records to the importer.","Avoid hand-editing export files; re-export instead.","Keep exporter and importer schema versions aligned.","Check for truncated writes if exports come from interrupted sessions."],"tags":["timestamp","import","parsing"],"backgroundTag":"invalid-date-format","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"}