Repository navigation
fix(app): show a load failure instead of an empty memories list on non-200 - #12654
Conversation
…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]>
There was a problem hiding this comment.
4 issues found across 109 files
Confidence score: 3/5
app/lib/backend/http/api/memories.dartcan misreportdeviceScopeSupportedwhen 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.dartkeeps the error screen visible during Retry, andapp/lib/providers/memories_provider.dartcan retainshowLoadErrorafterclearUserData(), leaving stale failure state across retries or sessions; disable or show progress during retry and reset_loadFailedwhen clearing data.app/lib/backend/http/api/memories.dartlogs 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(), |
There was a problem hiding this comment.
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}'); |
There was a problem hiding this comment.
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>
| 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, |
There was a problem hiding this comment.
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>
| false, | |
| fallback.ok ? false : fallback.deviceScopeSupported, |
| bool _deviceScopeSupported = true; | ||
| bool _ledgerHistorySupported = false; | ||
| bool _ledgerHistoryTruncated = false; | ||
| bool _loadFailed = false; |
There was a problem hiding this comment.
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>
What changed and why
During the 2026-08-17/18
/v3/memories503 outage (1,498 × 503 and zero 200s for 5.5 hours), the Flutter client returnedGetMemoriesResult([], …)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 existingcrashReporter.reportCrashpath used by otherapp/lib/backend/http/api/callers, and stops printing knowledge-graphresponse.bodyon screen.The 400 +
thisDeviceOnlylegacy fallback is unchanged: a backend that does not supportdevice_scope=currentstill refetches without that query and setsdeviceScopeSupported: falseso 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:
PATHput~/fvm/versions/3.44.5/binfirst (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 producedok == true; the knowledge-graph message containedSECRET_INTERNAL_TRACE.After the fix: the same tests plus provider and widget coverage passed (45 tests including existing memories deletion/ledger suites).
Mutation: omitting
failureReasonon non-200 and interpolating$bodyinto the knowledge-graph message made those tests fail again (ok == trueon 503; message contained the body). Restored.dart analyzeon the touched Dart files: no errors; 4 pre-existing infos (avoid_print, deprecated Share) not introduced here. Analyzer ratchet was not baselined.flutter gen-l10nstill warns 2 untranslated messages per locale (memoryHistoryPartial,tapPlusToStartRecording). Those keys are missing onorigin/mainas well; this PR's two new keys are present in all 49 ARBs.bash test.shinapp/: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 setsshowLoadError; 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 inapp/lib/backend/http/api/Fixed here:
memories.dartgetMemoriesResult— the incident path. Null, non-200 (except the 400thisDeviceOnlyfallback), and 200-decode failure now carryfailureReason+ status. Telemetry:Logger.error+PlatformManager.instance.crashReporter.reportCrash(same mechanism asconversations.dart/apps.dart).knowledge_graph_api.dart— opposite polarity: non-200 no longer interpolatesresponse.bodyinto the thrown message; body isLogger.debugonly.memory_graph_page.dartrenderscouldNotLoadKnowledgeGraph, note.toString().Left (not the identical two-line change; each needs its own result type / UI):
memories.dart:195,205getLedgerHistory— non-200 is "history projection unsupported" by contract, not "account has no history"; current list stays usable.memories.dartgetMemories()wrapper — still returns.memoriesonly;score_widget.dartis the remaining caller and is outside this surface.conversations.dart:104-115getConversationsResult— already returnsok: falseon non-200 (the pattern this PR copies).conversations.dart:220,231listGoogleCalendarEvents— picker helper; empty on error is "no events to pick".conversations.dart:243,256(calendar overlap helper) — same picker-style empty.conversations.dart:824,831getActionItems— emptyActionItemsResponseon non-200, same class, separate list UI.conversations.dart:843,851getConversationSuggestedApps— catalog empty on error.users.dart:219,232getAllPeople— people list empty on non-200.users.dart:559,566getDailySummaries— summaries empty on non-200.speech_profile.dart:67,79getExpandedProfileSamples— samples empty on non-200 (72,76are decode/shape guards on 200).phone_calls.dart:90,95getVerifiedPhoneNumbers— numbers empty on non-200.messages.dart:67,87getMessagesServer— chat empty on non-200 (74is empty 200 body).imports.dart:145,149getImportJobs— jobs empty on non-200.goals.dart:231,248getAllGoals— goals empty on non-200.folders.dart:11,23getFolders— 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 alreadyreportCrashon the catch path.announcements.dart:33,73— changelog/pending lists empty on non-200.New guards (only when adding a check or ratchet)
None.