fix(chat-migration): preserve full v1 serialized error when migrating to v2#16087
Open
EurFelux wants to merge 3 commits into
Open
fix(chat-migration): preserve full v1 serialized error when migrating to v2#16087EurFelux wants to merge 3 commits into
EurFelux wants to merge 3 commits into
Conversation
… to v2
The v1->v2 chat migrator converted v1 ErrorMessageBlocks to v2 `data-error` parts keeping only `name`/`message`, dropping every other field v1's `serializeError` attaches — `statusCode`/`status` and `providerId` (used by `classifyError`), `i18nKey` (translated display), and `finishReason`/`responseBody`/`data`/`url`/etc. (used by `ErrorDetailModal`).
As a result every migrated v1 error classified as 'unknown' on v2 — triggering the AI-diagnosis fallback (placeholder then delayed summary) — and lost its detail. Now spread the full serialized error, mirroring the live v2 persist path (`PersistenceListener` writes `data: { ...error }`).
Refs #16083
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: icarus <eurfelux@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
ChatMappings.transformSingleBlockToPart) converted a v1ErrorMessageBlockinto a v2data-errorpart keeping onlynameandmessage, discarding every other field v1'sserializeErrorattaches to the error.statusCode/statusandproviderId(used byclassifyError),i18nKey(translated display), andfinishReason/responseBody/data/url/stack/cause/etc. (used byErrorDetailModal). Migrated errors therefore classified asunknown— triggering the AI-diagnosis fallback (a generic "An error occurred" placeholder that only later swaps to an AI-generated summary) — and showed almost nothing in the detail view.After this PR:
data-errorpart (then defaultsname/messagetonull), mirroring the live v2 persist path (PersistenceListenerwritesdata: { ...error }). Migrated errors keep theirstatusCode/finishReason/i18nKey/providerId/ detail fields, soclassifyErrorresolves them immediately andErrorDetailModalshows the real details.Refs #16083
Why we need it and why it was done in this way
The following tradeoffs were made:
serializeErrorcan attach ~35 different fields (AI SDK error subtypes,i18nKey,providerId, ...), and v2'sclassifyError+ErrorBlock+ErrorDetailModalconsume a broad subset of them. A field-by-field allow-list would be brittle and would silently drop future fields. Spreading matches the live persist path exactly.oldBlock.error's runtime shape carries more than the narrowSerializedErrorDatatype models, so the fix relies on the spread (object spread copies all runtime own-props) plus anas ErrorPartDatacast at the use site; the values are already JSON-safe (v1 serialized them).The following alternatives were considered:
statusCode,finishReason): rejected — incomplete and brittle vs. the renderer's broad consumption and future additions.Breaking changes
None. Migrated
data-errorparts simply carry more fields; the v2 renderer already reads them when present.Special notes for your reviewer
transformSingleBlockToPartunit test (ChatMappings.test.ts).Checklist
Release note