{"record":{"id":"908e33f3bf01fc0d","repo":"Hmbown/CodeWhale","slug":"record-index-1-unsupported-schemaversion-a-schemaversion","errorCode":null,"errorMessage":"Record ${index + 1}: unsupported schemaVersion ${a.schemaVersion}.","messagePattern":"Record (.+?): unsupported schemaVersion (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/src/core/ingest.ts","lineNumber":127,"sourceCode":"}\nexport function attributes(value: unknown): Obj {\n  if (!Array.isArray(value)) return obj(value);\n  return Object.fromEntries(value.filter(x => typeof x?.key === 'string').map(x => [x.key, decodeAnyValue(x.value)]));\n}\nfunction ns(v: unknown, field: string): bigint {\n  if (typeof v === 'number' && !Number.isSafeInteger(v)) throw new Error(`${field} lost precision: encode OTLP nanoseconds as a decimal string.`);\n  const s = String(v ?? '');\n  if (!/^\\d{1,20}$/.test(s) || BigInt(s) > 18446744073709551615n) throw new Error(`Invalid ${field}: expected an OTLP nanosecond integer string.`);\n  return BigInt(s);\n}\nfunction otelStatus(v: unknown): Status {\n  const c = obj(v).code;\n  return c === 2 || c === 'STATUS_CODE_ERROR' ? 'error' : c === 1 || c === 'STATUS_CODE_OK' ? 'success' : 'unknown';\n}\nfunction normalizedEvent(v: unknown, index: number): WhaleEvent {\n  const a = obj(v), id = str(a.id), traceId = str(a.traceId), name = str(a.name);\n  if (!id || !traceId || !name) throw new Error(`Record ${index + 1} requires nonempty id, traceId, and name.`);\n  if (a.schemaVersion !== undefined && a.schemaVersion !== 1) throw new Error(`Record ${index + 1}: unsupported schemaVersion ${a.schemaVersion}.`);\n  const startTime = number(a.startTime, 'startTime', false)!;\n  const endTime = number(a.endTime, 'endTime') ?? startTime;\n  if (endTime < startTime) throw new Error(`Record ${index + 1}: endTime precedes startTime.`);\n  if (a.category !== undefined && !CATEGORIES.includes(a.category)) throw new Error(`Unknown category \"${a.category}\". Use \"other\" plus subtype for extensions.`);\n  const allowed: Status[] = ['pending', 'running', 'success', 'error', 'unknown'];\n  if (a.status !== undefined && !allowed.includes(a.status)) throw new Error(`Record ${index + 1}: invalid status.`);\n  const at = obj(a.attributes);\n  return {\n    schemaVersion: 1, id, traceId, name, parentId: str(a.parentId), startTime, endTime,\n    openEnded: a.endTime === undefined || a.openEnded === true,\n    agentId: str(a.agentId) ?? 'unattributed', agentType: str(a.agentType), parentAgentId: str(a.parentAgentId),\n    category: a.category ?? categoryFor(name, at), subtype: str(a.subtype),\n    model: str(a.model), provider: str(a.provider), tool: str(a.tool),\n    inputTokens: nonnegative(a.inputTokens, 'inputTokens'), outputTokens: nonnegative(a.outputTokens, 'outputTokens'),\n    cachedTokens: nonnegative(a.cachedTokens, 'cachedTokens'), cost: nonnegative(a.cost, 'cost'),\n    costCurrency: str(a.costCurrency), latency: nonnegative(a.latency, 'latency'),\n    contextTokens: nonnegative(a.contextTokens, 'contextTokens'), contextLimit: nonnegative(a.contextLimit, 'contextLimit'),\n    retry: nonnegative(a.retry, 'retry'), status: a.status ?? 'unknown',","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/src/core/ingest.ts#L109-L145","documentation":"normalizedEvent supports exactly schemaVersion 1. If a record carries a schemaVersion field with any other value, ingest rejects it (pet/src/core/ingest.ts:127) rather than guessing the shape — omitted schemaVersion is still accepted as v1.","triggerScenarios":"Ingesting records where a.schemaVersion is 2, '1' (string), or any value !== 1 after a producer upgrade.","commonSituations":"Producer upgraded to a newer schema before the ingest library did; schemaVersion serialized as a string instead of a number; copying a fixture from a different project with a different versioning scheme.","solutions":["Set schemaVersion to the number 1 or omit the field entirely","Upgrade the ingest library to a version that supports the producer's schema","Fix the producer to serialize schemaVersion as a number, not a string"],"exampleFix":"// before\n{..., schemaVersion: '1'}\n// after\n{..., schemaVersion: 1}","handlingStrategy":"validation","validationCode":"if (rec.schemaVersion!==undefined && rec.schemaVersion!==1) throw new Error('unsupported schemaVersion');","typeGuard":"const isV1Record=(r:any): r is {schemaVersion?:1} & Record<string,unknown> => r?.schemaVersion===undefined||r?.schemaVersion===1;","tryCatchPattern":"try { ingest(records); } catch (e) { if (/unsupported schemaVersion/.test(e.message)) { /* upgrade library or downgrade producer schema */ } else throw e; }","preventionTips":["Pin schemaVersion:1 in producer templates","Add a compatibility check between producer and ingest library versions","Serialize schemaVersion as a number, never a string"],"tags":["validation","schema-version","compatibility","ingest"],"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"}