Skip to content

fix(app): show a load failure instead of an empty memories list on non-200 - #12654

Merged
Git-on-my-level merged 1 commit into
mainfrom
agent/flutter-non200-empty
Sep 3, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
agent/flutter-non200-empty

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

What changed and why

During the 2026-08-17/18 /v3/memories 503 outage (1,498 × 503 and zero 200s for 5.5 hours), the Flutter client returned GetMemoriesResult([], …) for any non-200, so every mobile user saw an empty memories list: an outage delivered as apparent data loss, with no error in telemetry. This PR distinguishes a failed fetch from a genuine empty account, shows a retryable "Couldn't load memories" state, reports the failure through the existing crashReporter.reportCrash path used by other app/lib/backend/http/api/ callers, and stops printing knowledge-graph response.body on screen.

The 400 + thisDeviceOnly legacy fallback is unchanged: a backend that does not support device_scope=current still refetches without that query and sets deviceScopeSupported: false so local device filtering is skipped.

Product invariants affected

INV-MEM-1 (app/lib/pages/memories/**). This PR does not change product memory tiers, default access, or canonical collections. It only stops a non-200 memories fetch from rendering as an empty successful list.

How it was verified

Toolchain: PATH put ~/fvm/versions/3.44.5/bin first (Flutter 3.44.5 / Dart 3.12.2).

Red-first (unfixed helper, 2026-09-03): flutter test test/unit/memories_http_result_test.dart test/unit/knowledge_graph_error_message_test.dart — 1 passed, 5 failed. A 503 produced ok == true; the knowledge-graph message contained SECRET_INTERNAL_TRACE.

After the fix: the same tests plus provider and widget coverage passed (45 tests including existing memories deletion/ledger suites).

Mutation: omitting failureReason on non-200 and interpolating $body into the knowledge-graph message made those tests fail again (ok == true on 503; message contained the body). Restored.

dart analyze on the touched Dart files: no errors; 4 pre-existing infos (avoid_print, deprecated Share) not introduced here. Analyzer ratchet was not baselined.

flutter gen-l10n still warns 2 untranslated messages per locale (memoryHistoryPartial, tapPlusToStartRecording). Those keys are missing on origin/main as well; this PR's two new keys are present in all 49 ARBs.

bash test.sh in app/: 06:24 +1687 ~5: All tests passed!

Tests

  • app/test/unit/memories_http_result_test.dart — 503 / null / decode-failure are failed results, not empty success; a 200 [] remains a genuine empty account.
  • app/test/providers/memories_provider_load_failure_test.dart — failed fetch sets showLoadError; a failed refresh keeps previously loaded memories; a later 200 clears the error.
  • app/test/widgets/memories_load_error_test.dart — failed state renders the retry affordance, not "No memories yet".
  • app/test/unit/knowledge_graph_error_message_test.dart — user-facing knowledge-graph copy does not contain the response body.

Failure class (fixes)

Failure-Class: FC-denial-rendered-as-empty-success

Existing class. Its five prior declarations are backend/MCP and Bluetooth/Gmail permission surfaces; this is the generic Dart "any non-200 → empty list" instance that produced the 2026-08-17 user-visible shape. No registry edit in this PR.

Sweep: return [] / return const X([]) on non-200 in app/lib/backend/http/api/

Fixed here:

  • memories.dart getMemoriesResult — the incident path. Null, non-200 (except the 400 thisDeviceOnly fallback), and 200-decode failure now carry failureReason + status. Telemetry: Logger.error + PlatformManager.instance.crashReporter.reportCrash (same mechanism as conversations.dart / apps.dart).
  • knowledge_graph_api.dart — opposite polarity: non-200 no longer interpolates response.body into the thrown message; body is Logger.debug only. memory_graph_page.dart renders couldNotLoadKnowledgeGraph, not e.toString().

Left (not the identical two-line change; each needs its own result type / UI):

  • memories.dart:195,205 getLedgerHistory — non-200 is "history projection unsupported" by contract, not "account has no history"; current list stays usable.
  • memories.dart getMemories() wrapper — still returns .memories only; score_widget.dart is the remaining caller and is outside this surface.
  • conversations.dart:104-115 getConversationsResult — already returns ok: false on non-200 (the pattern this PR copies).
  • conversations.dart:220,231 listGoogleCalendarEvents — picker helper; empty on error is "no events to pick".
  • conversations.dart:243,256 (calendar overlap helper) — same picker-style empty.
  • conversations.dart:824,831 getActionItems — empty ActionItemsResponse on non-200, same class, separate list UI.
  • conversations.dart:843,851 getConversationSuggestedApps — catalog empty on error.
  • users.dart:219,232 getAllPeople — people list empty on non-200.
  • users.dart:559,566 getDailySummaries — summaries empty on non-200.
  • speech_profile.dart:67,79 getExpandedProfileSamples — samples empty on non-200 (72,76 are decode/shape guards on 200).
  • phone_calls.dart:90,95 getVerifiedPhoneNumbers — numbers empty on non-200.
  • messages.dart:67,87 getMessagesServer — chat empty on non-200 (74 is empty 200 body).
  • imports.dart:145,149 getImportJobs — jobs empty on non-200.
  • goals.dart:231,248 getAllGoals — goals empty on non-200.
  • folders.dart:11,23 getFolders — folders empty on non-200.
  • apps.dart:56,76,203,208,456,466,473,483,554,564,625,634,690,699 — catalog/enabled/review list helpers empty on non-200 or caught decode; several already reportCrash on the catch path.
  • announcements.dart:33,73 — changelog/pending lists empty on non-200.

New guards (only when adding a check or ratchet)

None.

Review in cubic

…n-200

GET /v3/memories 503s were rendered as "you have no memories". Distinguish
failed fetches from empty accounts and keep knowledge-graph errors off the
raw response body.

Co-Authored-By: cursor grok-4.6 <[email protected]>
Co-authored-by: Cursor <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 issues found across 109 files

Confidence score: 3/5

  • app/lib/backend/http/api/memories.dart can misreport deviceScopeSupported when the legacy 400 fallback also fails, which may cause callers to make incorrect capability decisions; preserve the fallback failure’s supported flag and only set it to false after a successful fallback response.
  • app/lib/pages/memories/page.dart keeps the error screen visible during Retry, and app/lib/providers/memories_provider.dart can retain showLoadError after clearUserData(), leaving stale failure state across retries or sessions; disable or show progress during retry and reset _loadFailed when clearing data.
  • app/lib/backend/http/api/memories.dart logs raw bodies for all non-200 responses, creating a potential sensitive-data exposure in debug logs; log only the status or a sanitized, bounded diagnostic.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/lib/pages/memories/page.dart">

<violation number="1" location="app/lib/pages/memories/page.dart:346">
P2: After the initial failure, tapping Retry leaves the same error screen rendered while `loadMemories()` runs because `_isInitialLoad` is already false and `_loadFailed` stays true until success. Disable the retry action or render a loading state while `provider.loading` is true to prevent repeated concurrent fetches and provide feedback.</violation>
</file>

<file name="app/lib/backend/http/api/memories.dart">

<violation number="1" location="app/lib/backend/http/api/memories.dart:145">
P2: When the legacy 400 fallback request itself fails, this result still reports `deviceScopeSupported: false` alongside the failure. Preserve the failure result's supported flag and set it to false only after a successful fallback, so failed fetches cannot be mistaken for confirmed unsupported `device_scope`.</violation>

<violation number="2" location="app/lib/backend/http/api/memories.dart:152">
P2: Every non-200 memories response now writes its raw body to debug logs. Log only the status (or a sanitized, bounded diagnostic) because server error bodies can contain sensitive content.</violation>
</file>

<file name="app/lib/providers/memories_provider.dart">

<violation number="1" location="app/lib/providers/memories_provider.dart:38">
P3: After `clearUserData()` follows a failed load, the provider still exposes `showLoadError` because `_loadFailed` is not cleared. Reset `_loadFailed` when clearing user data so logout and the next session do not inherit the previous account's outage state.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

child: Text(context.l10n.addFirstMemory),
child: MemoriesEmptyOrError(
showLoadError: provider.showLoadError,
onRetry: () => provider.loadMemories(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: After the initial failure, tapping Retry leaves the same error screen rendered while loadMemories() runs because _isInitialLoad is already false and _loadFailed stays true until success. Disable the retry action or render a loading state while provider.loading is true to prevent repeated concurrent fetches and provide feedback.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/pages/memories/page.dart, line 346:

<comment>After the initial failure, tapping Retry leaves the same error screen rendered while `loadMemories()` runs because `_isInitialLoad` is already false and `_loadFailed` stays true until success. Disable the retry action or render a loading state while `provider.loading` is true to prevent repeated concurrent fetches and provide feedback.</comment>

<file context>
@@ -338,33 +339,38 @@ class MemoriesPageState extends State<MemoriesPage> with AutomaticKeepAliveClien
-                                          child: Text(context.l10n.addFirstMemory),
+                                child: MemoriesEmptyOrError(
+                                  showLoadError: provider.showLoadError,
+                                  onRetry: () => provider.loadMemories(),
+                                  emptyState: Center(
+                                    child: Column(
</file context>

);
}
if (response != null && response.statusCode != 200) {
Logger.debug('getMemories error ${response.statusCode} body=${response.body}');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Every non-200 memories response now writes its raw body to debug logs. Log only the status (or a sanitized, bounded diagnostic) because server error bodies can contain sensitive content.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/backend/http/api/memories.dart, line 152:

<comment>Every non-200 memories response now writes its raw body to debug logs. Log only the status (or a sanitized, bounded diagnostic) because server error bodies can contain sensitive content.</comment>

<file context>
@@ -55,29 +135,34 @@ Future<GetMemoriesResult> getMemoriesResult({int limit = 100, int offset = 0, bo
+    );
+  }
+  if (response != null && response.statusCode != 200) {
+    Logger.debug('getMemories error ${response.statusCode} body=${response.body}');
+  }
+  final result = memoriesResultFromHttp(
</file context>
Suggested change
Logger.debug('getMemories error ${response.statusCode} body=${response.body}');
Logger.debug('getMemories error ${response.statusCode}');

return GetMemoriesResult(fallback.memories, false);
return GetMemoriesResult(
fallback.memories,
false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: When the legacy 400 fallback request itself fails, this result still reports deviceScopeSupported: false alongside the failure. Preserve the failure result's supported flag and set it to false only after a successful fallback, so failed fetches cannot be mistaken for confirmed unsupported device_scope.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/backend/http/api/memories.dart, line 145:

<comment>When the legacy 400 fallback request itself fails, this result still reports `deviceScopeSupported: false` alongside the failure. Preserve the failure result's supported flag and set it to false only after a successful fallback, so failed fetches cannot be mistaken for confirmed unsupported `device_scope`.</comment>

<file context>
@@ -55,29 +135,34 @@ Future<GetMemoriesResult> getMemoriesResult({int limit = 100, int offset = 0, bo
-    return GetMemoriesResult(fallback.memories, false);
+    return GetMemoriesResult(
+      fallback.memories,
+      false,
+      truncated: fallback.truncated,
+      statusCode: fallback.statusCode,
</file context>
Suggested change
false,
fallback.ok ? false : fallback.deviceScopeSupported,

bool _deviceScopeSupported = true;
bool _ledgerHistorySupported = false;
bool _ledgerHistoryTruncated = false;
bool _loadFailed = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: After clearUserData() follows a failed load, the provider still exposes showLoadError because _loadFailed is not cleared. Reset _loadFailed when clearing user data so logout and the next session do not inherit the previous account's outage state.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/providers/memories_provider.dart, line 38:

<comment>After `clearUserData()` follows a failed load, the provider still exposes `showLoadError` because `_loadFailed` is not cleared. Reset `_loadFailed` when clearing user data so logout and the next session do not inherit the previous account's outage state.</comment>

<file context>
@@ -35,6 +35,7 @@ class MemoriesProvider extends ChangeNotifier {
   bool _deviceScopeSupported = true;
   bool _ledgerHistorySupported = false;
   bool _ledgerHistoryTruncated = false;
+  bool _loadFailed = false;
   Future<void>? _clientDeviceInitialization;
   List<Tuple2<MemoryCategory, int>> categories = [];
</file context>

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