From 2a334c09326309f0fd94256306a89adf4e39b518 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 4 Jun 2026 18:14:59 +0300 Subject: [PATCH] warn on cache miss in restrictChatSettings surfaces the regression vector where an empty cache could drop or downgrade a server-side value for a dimension we're not restricting (PR review feedback) --- src/state/queries/messages/restrictChatSettings.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/state/queries/messages/restrictChatSettings.ts b/src/state/queries/messages/restrictChatSettings.ts index 5e252b5505..342906dd13 100644 --- a/src/state/queries/messages/restrictChatSettings.ts +++ b/src/state/queries/messages/restrictChatSettings.ts @@ -35,6 +35,18 @@ export async function restrictChatSettings({ }): Promise { const cached = getOtherRequiredDataFromCache({did})?.actorDeclaration + // When the cache is empty we fall back to defaults for any dimension we're + // not explicitly restricting, which could drop/downgrade a value the user + // has actually set server-side. The cache should be hydrated by + // prefetchOtherRequiredData before any of these paths fire, so log if that + // assumption ever breaks. (Restricting both dimensions is unaffected, so + // don't warn for the common signup/birthdate-change case.) + if (!cached && (!restrictIncoming || !restrictGroupInvites)) { + logger.warn( + `restrictChatSettings: cache miss, falling back to defaults for unrestricted dimensions`, + ) + } + const record: ChatBskyActorDeclaration.Main = { $type: 'chat.bsky.actor.declaration', allowIncoming: restrictIncoming