Skip to content

SCA-2800: fix(developer-api): serve a v3 row whose structured has no category - #25628

Merged
Git-on-my-level merged 2 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-opencode-deepseek-v4/88a431f871c8
Nov 17, 2026
Merged

Git-on-my-level merged 2 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-opencode-deepseek-v4/88a431f871c8

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What

The developer conversation read paths 500 or drop a v3 row whose structured has no category, 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; category arrives with the summary. The app's own Conversation model defaults title, overview and category (and, since #25588, a participant's missing source), so GET /v1/conversations and GET /v1/conversations/{id} serve those rows. Three other response models still required all three:

  • GET /v1/dev/user/conversations/{id}?include_transcript=true raised ResponseValidationError with exactly one error, structured.category missing, 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/conversations caught the same ValidationError per row and dropped the conversation from the page.
  • GET /v1/mcp/conversations dropped 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_defaults fills the same defaults the app model uses (title/overview empty, category other, an invalid or unhashable category folded to other) 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:

  • developer detail (read_conversation_item),
  • developer list (before Conversation.model_validate),
  • developer PATCH re-read,
  • MCP cards (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_card fills 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 source semantics for new rows, the share projection, participant identity/alias rules, or the v3 projection write path. The app routes keep a participant without source under transcript; the developer list/detail payloads have no participants field, so it is absent there.

Test command and output

$ cd backend && python -m pytest tests/unit/test_dev_api_conversations_poison.py -q
22 passed, 2 warnings in 1.39s

$ cd backend && python -m pytest tests/unit/test_mcp_conversations_poison.py -q
4 passed, 1 warning in 0.57s

The new cases fail on the pre-fix tree: both MCP cases (list drops, detail 404s) and the developer PATCH case (2 failed / 1 failed respectively). Related files, each in its own process:

test_mcp_data_endpoints.py             116 passed
test_mcp_detail_views.py                27 passed
test_chat_addressable_refs.py           16 passed
test_mcp_sse_pagination_bounds.py        9 passed
test_home_transcribing_hold.py         110 passed
test_developer_read_routes.py            6 passed
test_conversations_v3_participant_source.py 2 passed

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

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]>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T19:01:31.998924Z
We couldn’t complete this review. Comment @codex review to try again.
6f6ab96 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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]>
@Git-on-my-level Git-on-my-level changed the title fix(developer-api): serve a v3 row whose structured has no category SCA-2800: fix(developer-api): serve a v3 row whose structured has no category Nov 17, 2026
@Git-on-my-level
Git-on-my-level merged commit f426f22 into BasedHardware:main Nov 17, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant