Repository navigation
fix(desktop): accept newer desktop finalization reasons in from-segments (#19328) - #19353
Merged
Merged
Conversation
…nts (#19328) TranscriptionFinalizationReason on macOS desktop grew 10 new stop-reasons (paywall, microphone_unavailable, stt_fallback, etc.) that the backend's conversation_finalization_reason Literal never learned about, so every local_segments upload carrying one of them failed Pydantic validation with a silent 422 and the recording was never recovered (retries resend the same value). The field is opaque client metadata -- only 'max_duration_rotation' is ever compared downstream -- so it now accepts any string instead of a closed, driftable enum.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Git-on-my-level
added a commit
that referenced
this pull request
Oct 28, 2026
… session ids (#15500) (#23886) ## What changed and why Fixes #15500 (still-live wave). macOS desktop recordings were stranded locally with HTTP 422 on every upload retry: the from-segments wire model rejected a blank/whitespace `client_session_id` (under any accepted alias) as a hard 422, and clients that persisted a blank id retried identical bytes forever — measured ~16–18k 422s/day on `/v1/conversations/from-segments` since 2026-10-06 (stable rollout of desktop v0.12.447 scaled a long-standing ~200/day baseline ~80×; ~670 sessions stuck on the hourly retry cadence). The id is optional metadata whose only job is retry dedupe, so a blank value is now treated as absent instead of rejecting the only copy of a transcript. The desktop client also no longer uploads a blank stored id (the chunked continuation path requires a real id), so both sides are closed. A blank id additionally no longer falls into the unkeyed create path (Luna review of this PR): these clients resend byte-identical requests, so if the first attempt's 200 is lost while its row lands, a plain create path would fork a duplicate conversation on retry. The server now derives a stable retry identity (`derived:<sha256>` over uid + the recording's own facts — source, started/finished timestamps, language, geolocation, segments) and runs the normal keyed idempotency path with it. Fields a retry may legitimately resend differently (folder, calendar context, client projection, finalization reason) stay out of the hash, so a retry lands on the first attempt's conversation. An id that was never sent keeps the public create-path contract unchanged; `null` counts as absent, not blank. The derived id never appears in the OpenAPI schema. ## Chunked uploads (recovery boundary) Chunked continuation uploads still require a real session id and keep their 422 when the id is blank: each chunk carries different segments, so a per-request payload hash is not stable across chunks of one recording, and a metadata-only hash (the only cross-chunk input) would key two distinct recordings that share timestamps into one chunk namespace (409 content conflict). The chunked blank-id cohort therefore recovers only after the desktop release ships the client-side fallback id (`desktop/macos/Desktop/Sources/ConversationFinalizationService.swift:873`, derived from the persistent SQLite row id + `startedAt`, stable across retries and app restarts); the local retry queue keeps retrying on capped hourly backoff, so those sessions drain once the update is installed. Non-chunked blank-id sessions drain on their next hourly retry after the backend deploy alone. ## Product invariants affected none ## How it was verified - Production aggregates (read-only, status codes and sizes only, no user data): daily 422 counts on the route 2026-09-01→10-28; response-size fingerprints of the failing bodies matched locally-generated validation errors for blank `client_session_id` values (aliases `client_session_id`/`session_id`/`client_id`, whitespace lengths 2–8); failing UAs are desktop builds 12402→12541; failing requests are 3KB–638KB real transcript payloads (not truncations). - Backend: `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_developer_from_segments_idempotency.py tests/unit/test_client_segment_continuation.py tests/unit/test_openapi_contract.py tests/unit/test_client_processing_acceptance.py` (unit layer), including the replay test below. - Desktop: focused XCTest `TranscriptionFinalizationStateMachineTests/testLocalClientConversationIdNeverUploadsABlankStoredId` via `scripts/dev-feedback.py --once swift` (unit layer). - Stranded-recovery: after the backend deploy, a stuck non-chunked session's next hourly retry sends the identical bytes and now lands (200 → markSessionCompleted → drained, no user action). Chunked-cohort sessions drain after the app update ships the fallback id. Retry-forever policy (#19613) confirmed on main: `.permanent` failures stay queued at hourly cadence and the recovery query includes rows old builds stranded at retryCount ≥ 5. ## Tests - `test_blank_client_session_id_gets_server_derived_retry_identity` (parametrized 4 aliases × 4 blank shapes): posts blank ids through the real route and asserts the keyed idempotency path runs with a `derived:` session id instead of a 422 — this test fails on main. - `test_byte_identical_blank_id_retry_returns_first_conversation`: the stuck cohort's retry shape (first attempt's 200 lost, row landed, identical bytes resent) returns the first conversation and never reprocesses — the exact duplicate-conversation gap from the review. - `test_blank_id_different_recordings_stay_separate`: different recording facts derive different ids and still create two conversations. - `test_sent_blank_flag_distinguishes_sent_blank_from_absent`: omitted and `null` ids stay on the create path; only a sent blank string derives. - `test_client_session_id_with_content_still_strips_and_dedupes`: real ids still strip and keep the idempotency path. - `testLocalClientConversationIdNeverUploadsABlankStoredId`: nil/empty/whitespace stored ids fall back to the derived id; padded ids still strip. ## UI evidence UI-Evidence: none -- backend validation and upload-id derivation only; no visible UI changed Line-Count-Exception: backend/routers/developer.py | 2830 -> 2862 | derived blank-id retry identity helper sits beside the existing from-segments idempotency helpers it extends Failure-Class: new ## Failure-class transition narrative `FC-optional-client-metadata-fails-closed` (definition added in this PR). - Violated contract: ingestion endpoints that receive the only copy of user data must degrade broken **optional** client metadata to absent, never 422 — a retrying client resends identical bytes, so a hard 422 strands the recording forever. Evidence: ~16–18k 422s/day on `/v1/conversations/from-segments` since 2026-10-06 from desktop builds 12402→12541, ~670 sessions stuck on the hourly retry cadence (#15500), caused by blank `client_session_id` values hitting the model's `cannot be empty` raise. - Canonical guard: blank values normalize to `None` at the wire model, and a sent-blank id derives a stable server-side retry identity so the byte-identical retry is an idempotency hit, never a duplicate conversation. The parametrized regression test posts blank ids under every accepted alias through the real route and asserts the keyed path runs with the derived id instead of a 422; the replay test pins the lost-200 retry to one conversation. - Supporting evidence: the artifact file already carries this guard plus the #19353 finalization-reason guard for the same endpoint. Distinct from FC-server-bound-excludes-client-design-range (server range excludes valid client design values): here the client metadata itself was broken and the server's job was to degrade, not to widen a bound. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23886?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://cubic.dev/action/auto-fix/pr/BasedHardware/omi/23886?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23886&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
kriegcloud
pushed a commit
to kriegcloud/omi
that referenced
this pull request
Oct 28, 2026
… session ids (BasedHardware#15500) Every macOS desktop upload carrying a blank persisted client id has been rejected with a 422 and retried with identical bytes forever: measured 16-18k 422s/day on /v1/conversations/from-segments since 2026-10-06 (the stable rollout of v0.12.447 scaled a long-standing ~200/day failure ~80x; ~670 sessions stuck on the hourly retry cadence), response bodies fingerprint-matching blank client_session_id values under the model's alias keys. The Sep-26 wave was BasedHardware#19353 (finalization reasons); this is the second, still-live wave of the same report. The id is optional metadata whose only job is retry dedupe, and every caller already handles its absence, so a blank value is now treated as absent instead of rejecting the only copy of a transcript. The desktop side never uploads a blank stored id either: the chunked continuation upload requires a real session id, so localClientConversationId trims the stored value and falls back to the derived id when blank. Stuck sessions drain without user action: after the backend deploy the next hourly retry of identical bytes lands; chunked-cohort sessions drain once the desktop fix ships. Failure-Class: new (FC-optional-client-metadata-fails-closed — ingestion of the only copy of user data must degrade broken optional metadata to absent, never 422; guard: test_blank_client_session_id_is_treated_as_absent)
This branch was successfully deployed
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.
Bug
Fixes #19328. Every macOS desktop recording finalized via the
local_segmentsstrategy has silently failed to upload since 2026-09-23, with
HTTP error: 422on every attempt and no user-visible error. The transcript is the only artifact
(no audio is retained), so a stuck session is a permanently lost recording.
Root cause
de517cf858(#17828, 2026-09-23) added 10 newTranscriptionFinalizationReasoncases to the desktop client (
paywall,microphone_unavailable,stt_fallback, etc.) without updating the backend's matchingLiteralforconversation_finalization_reasononPOST /v1/conversations/from-segments(
backend/routers/developer.py). Any session stopped for one of those 10reasons sends a value FastAPI/Pydantic rejects before the handler runs — an
automatic 422 — and
ConversationFinalizationService.markRetryableFailureonly logs and reschedules, so every retry resends the identical value and
422s again, forever (
retryCount 5,backendSynced 0, and it survives apprestarts, matching the report).
Sessions using the older
cloud_reconcilefinalization path never send thisfield at all, which is why "cloud" sessions kept working while
local_segmentssessions silently stopped.
Fix
conversation_finalization_reasonis opaque client-versioned metadata — theonly downstream logic that inspects it is one exact-string comparison against
'max_duration_rotation'(backend/utils/conversations/meeting_treatment.py).Rather than re-widening a
Literalthat will drift out of sync again the nexttime desktop adds a stop-reason, it's now a plain
Optional[str], so thebackend accepts whatever reason the client's own enum produces.
What I tested
test_from_segments_accepts_newer_desktop_finalization_reasons(parametrized over all 10 new reasons) to
backend/tests/unit/test_developer_from_segments_idempotency.py.pytest backend/tests/unit/test_developer_from_segments_idempotency.py— 42passed.
pytest backend/tests/unit/test_meeting_treatment.py tests/unit/test_listen_finalization_cloud_tasks.py tests/unit/test_chat_first_proactive_engine.py— 137 passed (confirms theone downstream consumer of this field is unaffected).
desktop/macos/CHANGELOG.json, unreleased).Failure-Class: FC-server-bound-excludes-client-design-range
🤖 automated by hourly watchdog — tested and merged