Repository navigation
fix(webchat): discard corrupted guest conversation ids and surface load failures - #1609
Merged
Merged
Conversation
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
…ad failures (#1609)
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.
Problem
createGuestSessionStore#initGuestSessiontrusted any guest conversation id found inlocalStorage(scoped or legacy) without validating its shape. A corrupted/stale value (e.g. leftover from an older widget version) was forwarded as-is to the guest message API, which always 400s on it — permanently stranding that visitor's session until they manually clear storage.Separately,
WebchatMessageListcalledloadMoreMessageswithout a.catch. That function onlyconsole.errors + rethrows on failure (network error, rate limit, invalid guest id), so the rejection was silently swallowed and the visitor saw an empty chat with no indication anything went wrong.Fix
isValidGuestConversationId(new, inguest-conversation-id.ts) validates a stored id against the existingGUEST_CONVERSATION_ID_REGEX.initGuestSessionnow discards a scoped or legacy stored id that fails validation (with aconsole.warn), falls back to the server-minted id for this page load, and overwrites storage so the corrupted value doesn't persist.WebchatMessageListnow catches a failed initialloadMoreMessagesand surfaces atoast.errorvia a newwebchat.loadMessagesErrortranslation key (added to all locales).Testing
pnpm --filter builder check-types— pass.pnpm lint(includesi18n:checkandultracite check) — pass, no missing/invalid translation keys.