v0-format sessions fail to project after v0→v3 migration: unguarded message.content reads in stock projections
#6686
Replies: 3 comments 1 reply
|
Independent confirmation of the two reads I could check on the installed 0.1.5-rc.2 tree, plus a tool-side consequence you may not have considered. The unguarded reads are exactly where you say. I could verify two of the three directly: Both are plain property chains with no optional chaining, in a A second consequence: this is also a robustness test for anything that reads session logs, including diagnostics. We build an offline doctor that scans session archives, so I took your root cause and built a fixture with both shapes ( What we added as a result (released in
To be explicit about the boundary: we detect the shape, we do not fix the projection. The graceful-degradation patch is yours to land upstream (and One suggestion for the report itself: if the patch is against |
|
Confirmed on master (c291e79) — and I can add the third location moonquake2004 couldn't confirm from the build artifact. The three unguarded reads:
On "should the migrator synthesize envelopes": it already partially does — (Your Windows repro I can't run; the source-level confirmation above is what I can honestly offer.) |
|
Thanks for closing the third location — that is precisely the part I could not do: I was reading the build artifact and could only confirm two of the three, while you read One piece of data we can add: the shape does not appear in every store. Using the real migration chain ( So it is not "every migrated session" — it depends on the specific v0 content, which fits your symptom being reproducible on your store and not universal. If you can say which v0 event kinds were involved when it does happen (even one sanitized excerpt), the discriminator would be pinned down — and it would tell us whether our check needs a second trigger. Ours is macOS with sessions from that era, so a Windows-only path looks unlikely; a specific v0 shape (a cancelled step, or one of the pass-through branches you identified at Your report has now improved our detection twice, and the second time was a correction to ourselves. I added On the contract question, your reading matches mine. If Shipped in |
Uh oh!
There was an error while loading. Please reload this page.
Environment
dsh-v0.1.5-rc.2, commit fb2c4b9)Symptom
Opening a historical v0-format session fails hard — the whole session becomes
unopenable:
Other sessions (newer format) are unaffected, so this only bites the long tail
of pre-upgrade logs after the automatic v0→v3 migration.
Root cause
After the v0→v3 migration, some events carry no message body:
assistant/message/tool/resultevents wheredata.messageisundefinedsurfaceOprecords with no resolvablestart/endThree stock projections assume the migrated shape is always complete and read
through it unguarded, so one legacy event aborts the entire
hydrate():session-turn-outline/src/projection.tsevent.data.source.kindandpreview(event.data.content, …)(user/message)preview(event.data.message.content, …)(assistant/message)session-stats/src/projection.tsevent.data.message.source.callId(tool/result)session-telemetry/src/coordinator.tsevent.data.message.content[0].isError(tool/result)(The same shape also trips third-party projections, e.g. a live-token-usage
plugin that prices
message.content; that part is the plugin author's to fix,but the stock projections are what make the session unopenable.)
Suggested fix
Make the stock projections degrade gracefully on under-filled migrated events
instead of throwing — optional chaining plus a neutral fallback. A patch
against 0.1.5-rc.2 is attached (
dsh-015-legacy-projection.patch); it onlytouches the three projection files, no format/migration logic.
message?.content ?? '',source?.kind,content ?? []message?.source?.callId+ treat a missing envelope as anunmatched call (skip the timing sample)
message?.content?.[0]?.isError,reason?.kindNotes
minimal message envelope instead, so downstream consumers see a complete
shape; the defensive reads above are the minimal-risk option either way.
附:补丁文件
dsh-015-legacy-projection.patch
All reactions