fix(app): handle 409 canonical state gracefully on knowledge graph rebuild (#20481)
Merged
ME
2mo ago+145+145+012345678901234567890123456789-20-20-01234567890123456789
Summary
Handle HTTP 409 Conflict (CANONICAL_GRAPH_MUTATION_CONFLICT) gracefully in KnowledgeGraphApi.rebuildKnowledgeGraph().
When an account has established canonical memory graph state, the backend rejects legacy graph mutations and returns HTTP 409. In the onboarding prebuild path (wrapper.dart), rebuildKnowledgeGraph() is called when no graph exists.
Changes
- In
KnowledgeGraphApi.rebuildKnowledgeGraph(), intercept HTTP 409 and return a syntheticcanonical_up_to_datestatus response instead of throwing an unhandled exception. - In
_prebuildKnowledgeGraph(), recognizecanonical_up_to_dateand exit early so onboarding does not poll for a background job that was never queued. - Add unit tests verifying
rebuildKnowledgeGraph()converts HTTP 409 tocanonical_up_to_date, parses HTTP 200, and throws sanitized error messages on HTTP 500 without leaking backend internals. - Include mobile release changelog fragment.
Verification
- Flutter unit tests:
flutter test test/unit/knowledge_graph_error_message_test.dart(5/5 passed) - Preflight:
scripts/pr-preflight --pr-body-file draft_pr_body.md
Failure class (fixes)
Failure-Class: none
Product invariants affected
none