fix(app): handle 409 canonical state gracefully on knowledge graph rebuild (#20481)

Merged
ME
2mo ago
+145-20

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 synthetic canonical_up_to_date status response instead of throwing an unhandled exception.
  • In _prebuildKnowledgeGraph(), recognize canonical_up_to_date and exit early so onboarding does not poll for a background job that was never queued.
  • Add unit tests verifying rebuildKnowledgeGraph() converts HTTP 409 to canonical_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