fix(app): treat benign 404 as recovery in processInProgressConversation (#9241)#9340
Merged
kodjima33 merged 1 commit intoJul 10, 2026
Merged
Conversation
POST /v1/conversations (process in-progress conversation) returns 404 when there is no in-progress conversation to process. This happens as a benign race: the WS auto-finalize path already consumed the in-progress conversation and cleared its Redis pointer before this client-initiated create ran, so the conversation is already finalized and there is nothing to recover. Previously every non-200 response was crash-reported, so this race flooded crash reporting with noise that has no user-visible impact (the caller already recovers gracefully by removing the '0' processing placeholder on null). Now a 404 is logged and skipped; other non-200 responses still report a crash. Extracted isBenignInProgressConversationCreateStatus for a hermetic regression test, mirroring the codebase pattern of testing branching logic via a minimal abstraction (the makeApiCall/crashReporter singletons aren't injectable). fixes #9241
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
processInProgressConversation()inapp/lib/backend/http/api/conversations.dartused to crash-report every non-200 response fromPOST /v1/conversations. A benign 404 now short-circuits to a debug log instead of a crash report; all other non-200 statuses still report a crash.Why
The backend endpoint (
backend/routers/conversations.py:162-165) raises404 "Conversation in progress not found"when there is no in-progress conversation to process:This is exactly the race described in the issue:
When the WS auto-finalize path finalizes the in-progress conversation and clears its Redis pointer first, a client-initiated create that races in finds nothing to process → 404. The conversation is already finalized, so there is nothing to recover — but the old code reported it as
Exception('Failed to create conversation'), flooding crash reporting with noise that has no user-visible impact. The caller incapture_controller.dartalready recovers gracefully on anullreturn (it removes the'0'processing placeholder).Change
Logger.debug(...)and returnnull(benign, already-finalized).isBenignInProgressConversationCreateStatus(int)so the crash-vs-skip decision is covered by a hermetic regression test (themakeApiCall/crashReportersingletons aren't injectable — this mirrors the existingsync_response_handling_test.dartpattern of testing branching logic via a minimal abstraction).Verified
nullwithout side effects.app/test/unit/process_in_progress_conversation_test.dartasserting 404 is benign and 304/400/401/409/429/5xx still report.app/test.shin this environment — the build machine has no Flutter/Dart SDK. CI (apptests) will exercise the new unit test. The change is a single status-code branch with no visual surface.Auto-generated from issue feedback by the mini issues-improver. Review before merge.