Skip to content

refactor(app): decode the capture-group separate ack through its generated model - #18491

Merged
kodjima33 merged 2 commits into
mainfrom
fix/capture-group-separate-generated-decode
Sep 25, 2026
Merged

kodjima33 merged 2 commits into
mainfrom
fix/capture-group-separate-generated-decode

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

tests/unit/test_app_client_schema_inventory.py::test_inventory_openapi_route_response_decode_migration_complete has been red on main since 373126c05e (#17297). Every PR that merges main past that commit inherits the failure in Backend unit shard 3/4.

The single violation is separateConversationFromCaptureGroup in app/lib/backend/http/api/conversations.dart, which hand-decodes a REST response that has a declared DTO:

final body = jsonDecode(response.body);
final status = body is Map ? body['status'] : null;

POST /v1/conversations/{conversation_id}/capture-group/separate returns StatusResponse in the app-client contract, so the migration gate expects that decode to run through the generated wire model rather than a raw field access.

What changed

  • StatusResponse added to the misc generator group. It is the canonical {'status': str} ack shared by 47 routes, so it belongs next to the other cross-cutting response schemas (FcmTokenResponse, RebuildResponse, ErrorResponse) rather than in conversation.
  • misc_wire.g.dart regenerated, adding GeneratedStatusResponse.
  • The decode now runs through that model.

Behavior is unchanged: the same unchanged discriminator selects the same result, and the existing catch still maps a malformed body to separated.

Verification

check result
test_app_client_schema_inventory.py 12 passed (was 1 failed, 11 passed)
same test @ 373126c05e 1 failed, 11 passed
same test @ 373126c05e^ 12 passed
generate_dart_models.py --all --check rc=0

Bisected on pristine detached worktrees rather than inferred, so the regression point is pinned rather than guessed.

A note on formatting

The added lines are format-clean under the pinned Flutter 3.44.5 toolchain (Dart 3.12.2). The rest of conversations.dart is deliberately left untouched: main's copy already differs from what that toolchain's dart format --line-length 120 emits, in four regions unrelated to this change, so reformatting them here would bury a two-line fix in unrelated churn. Worth a separate look at whether the committed file and the pinned toolchain have drifted apart.

🤖 Generated with Claude Code

Review in cubic

…rated model

tests/unit/test_app_client_schema_inventory.py::
test_inventory_openapi_route_response_decode_migration_complete has been red on
main since 373126c (#17297). Its one violation is
separateConversationFromCaptureGroup, which hand-decodes a REST response that
has a declared DTO:

    final body = jsonDecode(response.body);
    final status = body is Map ? body['status'] : null;

POST /v1/conversations/{conversation_id}/capture-group/separate returns
StatusResponse in the app-client contract, so the migration gate expects the
decode to run through the generated wire model rather than a raw field access.

StatusResponse is the canonical {'status': str} ack shared by 47 routes, so it
is added to the misc group -- next to the other cross-cutting response schemas
-- rather than to conversation, and misc_wire.g.dart is regenerated.

Behavior is unchanged: the same 'unchanged' discriminator selects the same
result, and the existing catch still maps a malformed body to separated.

Verified: 12 passed (was 1 failed, 11 passed), reproduced red at 373126c and
green at 373126c^; generate_dart_models.py --all --check rc=0. The added
lines are format-clean under the pinned Flutter 3.44.5 toolchain; the file's
other regions are left untouched because main's copy already differs from what
that toolchain's dart format emits.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end — this un-breaks the schema-inventory gate on main.

Reproduced independently in detached worktrees:

  • at base 29b3c32: tests/unit/test_app_client_schema_inventory.py → 11 passed, 1 failed (test_inventory_openapi_route_response_decode_migration_complete, violation in app/lib/backend/http/api/conversations.dart)
  • at this head: 12 passed
  • backend/scripts/generate_dart_models.py --all --check → rc=0, so app/lib/backend/schema/gen/misc_wire.g.dart is genuine generator output, not hand-edited

Per-file notes:

  • app/lib/backend/http/api/conversations.dart — decode parity holds branch-for-branch: 'unchanged' → CaptureGroupSeparationResult.unchanged, anything else → separated, and a missing/null/non-string status now throws FormatException inside GeneratedStatusResponse.fromJson which the existing catch maps to separated, same as the old null path. No behavior change.
  • app/lib/backend/schema/gen/misc_wire.g.dart — GeneratedStatusResponse matches the generator's required-field helpers; mirrors backend/models/shared.py StatusResponse ('ok'/'unchanged' per the route handler).
  • backend/scripts/generate_dart_models.py — adding StatusResponse to the 'misc' group is the right placement: 47 OpenAPI operations reference it, so it's cross-cutting and belongs beside FcmTokenResponse/RebuildResponse/ErrorResponse rather than in the conversation group.
  • app/changelog/unreleased/20260924-capture-group-ack-generated-decode.json — {"kind": "none"} matches the sibling unreleased pattern for a no-user-visible-change refactor.

The commit message's bisection claim checks out: 373126c is #17297. No CI/workflow files touched; required checks green including Dart Analyze & Tests and the Backend unit suite. Leaving formal approval to a human maintainer.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Sep 24, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor(app), not a bug/feature fix by title -- approve-only per policy regardless of score, even though it fixes a real red test inherited by every PR (test_inventory_openapi_route_response_decode_migration_complete). CI green (46/46).

…arate-generated-decode

# Conflicts:
#	app/lib/backend/http/api/conversations.dart
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Conflicts resolved on 7d9f255016 — merge of current main (60 commits).

main landed the same handler fix independently via 4ec7cb461b (#18483) while this was open, placing StatusResponse in the conversation generator group. The merge left it in both groups, so GeneratedStatusResponse was emitted into conversation_wire.g.dart and misc_wire.g.dart. Resolved by removing the conversation entry and regenerating both groups, so the schema has exactly one home.

Checked before removing it rather than assuming: grep for GeneratedStatusResponse across app/lib finds a single caller — the one line in conversations.dart — so nothing else depended on the conversation copy.

What this PR now contributes, on top of main, is the placement: StatusResponse is the canonical {'status': str} ack referenced by 47 OpenAPI operations, so it sits beside FcmTokenResponse/RebuildResponse/ErrorResponse in misc rather than inside a conversation-specific bundle.

check result
test_app_client_schema_inventory.py 12 passed
generate_dart_models.py --all --check rc=0
GeneratedStatusResponse defined in misc_wire.g.dart only

5 files, +24/−22. The approval predates this merge, so it may need re-confirming.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trusted contributor; fixes a real red-on-main test regression, scoped diff, CI green.

@kodjima33
kodjima33 merged commit d8a8878 into main Sep 25, 2026
59 checks passed
@kodjima33
kodjima33 deleted the fix/capture-group-separate-generated-decode branch September 25, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants