fix(session-persistence-jsonl): reject empty zstd artifacts
A present zero-byte .jsonl.zstd file was treated as though no artifact existed because readRaw returned undefined when frame scanning found nothing. That contradicted both the plaintext path and the logical zstd reader, and it made the export endpoint answer 404 for on-disk corruption. Treat a present artifact without a complete header frame as corruption and reuse the zstd reader's existing diagnostic. The regression test now distinguishes an existing empty file from an absent path, and the bilingual JSONL storage contract records that zero-frame artifacts reject alongside other header and frame failures.
This commit is contained in:
@@ -259,7 +259,7 @@ export class SessionPersistenceJsonl extends SessionPersistence implements Persi
|
||||
let content: string
|
||||
if (this.compression === 'zstd') {
|
||||
const { frames } = scanZstdFrames(buffer)
|
||||
if (frames.length === 0) return undefined
|
||||
if (frames.length === 0) throw new Error('empty or header-less Zstandard session log')
|
||||
const decoder = createZstdFrameDecoder()
|
||||
const plaintexts: Buffer[] = []
|
||||
// The decoder yields views into a reused buffer; copy each frame's
|
||||
|
||||
Reference in New Issue
Block a user