Repository navigation
SCA-2800: fix(developer-api): serve a v3 row whose structured has no category - #25628
Merged
Git-on-my-level merged 2 commits intoNov 17, 2026
Conversation
The developer conversation response model required structured.category, but a v3 row written before its summary carries only title/overview/emoji/sections/ participants. The detail route therefore raised ResponseValidationError (one missing field) and 500'd, while the list route silently dropped the same rows from the page. BasedHardware#25588 fixed the app's own Conversation model for a participant with no source; the developer projection stayed stricter than the read seam. Project the stored structured through the same defaults the app model uses (title/overview empty, category other, invalid category folded to other) before validation on both the list and detail routes. The stored document is never rewritten and the published schema still requires the fields. Failure-Class: FC-response-model-decoupled-from-projection Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The first round fixed the developer list and detail routes; review found the same response-model gap on the developer PATCH re-read and the MCP conversation surfaces. The PATCH path persisted the title and then 500'd on the re-read, so the client saw a failure for a write that landed. MCP dropped a v3 row without category from the list and turned it into a 404 on detail. Move the projection into utils/conversations/structured_defaults.py and apply it to the developer list/detail/PATCH and to conversation_card (MCP list, search, detail and tool handlers). The projection returns a copy, folds an out-of-enum or unhashable category to other, and leaves MCP's existing malformed-row skip guard deciding for a bad category value — only a missing field is filled there. The stored document is never rewritten. Tests cover a missing, out-of-enum and unhashable category on both developer routes, the PATCH write, the copy-not-mutate contract, and the MCP list/detail. Failure-Class: FC-response-model-decoupled-from-projection Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
The developer conversation read paths 500 or drop a v3 row whose
structuredhas nocategory, and the MCP conversation read paths drop it (list) or 404 it (detail).A v3 row written before its summary carries only
title/overview/emoji/sections/participants;categoryarrives with the summary. The app's ownConversationmodel defaultstitle,overviewandcategory(and, since #25588, a participant's missingsource), soGET /v1/conversationsandGET /v1/conversations/{id}serve those rows. Three other response models still required all three:GET /v1/dev/user/conversations/{id}?include_transcript=trueraisedResponseValidationErrorwith exactly one error,structured.categorymissing, and returned 500.PATCH /v1/dev/user/conversations/{id}persisted the title, then returned 500 on the re-read, so the client saw a failure for a write that landed.GET /v1/dev/user/conversationscaught the sameValidationErrorper row and dropped the conversation from the page.GET /v1/mcp/conversationsdropped the row;GET /v1/mcp/conversations/{id}turned it into a 404.This is the residual on SCA-2800: the list half was fixed by #25588, the other read surfaces were not.
Fix
project_structured_defaultsfills the same defaults the app model uses (title/overviewempty,categoryother, an invalid or unhashable category folded toother) before the response model validates. It returns a copy, so a shared or cached row never carries the projected defaults onward, and the stored document is never rewritten. The published schemas still require the fields, matching the #25588 pattern.Applied on:
read_conversation_item),Conversation.model_validate),conversation_card, so list/search/detail and the MCP tool handlers all share one projection). The MCP call keeps its existing disposition for a malformed category: only a missing category is filled, so an out-of-enum value still reaches the MCP per-record skip guard.Diff scope
backend/utils/conversations/structured_defaults.py— new shared projection.backend/utils/developer_item_reads.py— detail route uses it.backend/routers/developer.py— list and PATCH use it (no line-count growth).backend/utils/mcp_server/helpers.py—conversation_cardfills the missing fields.backend/tests/unit/test_dev_api_conversations_poison.py— v3 row through list/detail for a missing, out-of-enum and unhashable category; PATCH case asserting 200 and the title write; app-model disposition; copy-not-mutate.backend/tests/unit/test_mcp_conversations_poison.py— v3 row without category survives the MCP list and detail.No change to
sourcesemantics for new rows, the share projection, participant identity/alias rules, or the v3 projection write path. The app routes keep a participant withoutsourceundertranscript; the developer list/detail payloads have no participants field, so it is absent there.Test command and output
The new cases fail on the pre-fix tree: both MCP cases (
listdrops,detail404s) and the developer PATCH case (2 failed/1 failedrespectively). Related files, each in its own process:Kill switch
Revert this commit. The developer list/detail/PATCH return to 500 or dropping such rows, the MCP list/detail to dropping or 404ing them, and no data changes.
Product invariants affected
none
Failure class (fixes)
Failure-Class: FC-response-model-decoupled-from-projection