From 57a6168bbc929a18c56e381eda220d37484b1bf4 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 17 Jul 2026 17:24:22 +0300 Subject: [PATCH] address claude review: getErrorStatus in feed 429 check, fix reportSubject docs - PostFeedErrorMessage read error?.status directly; only XrpcResponseError carries .status now, so route through getErrorStatus() like the rest of detectKnownError (also drops an oxlint no-unsafe-member-access suppression). - reportSubject.ts docblocks contradicted each other about cid branding; l.CidString is a plain (unbranded) string alias, so the file docstring now says so and the strongRef comments agree. Co-Authored-By: Claude Fable 5 --- oxlint-suppressions.json | 2 +- .../moderation/ReportDialog/utils/reportSubject.ts | 13 +++++++------ src/view/com/posts/PostFeedErrorMessage.tsx | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json index 6267907f16..cc97daab69 100644 --- a/oxlint-suppressions.json +++ b/oxlint-suppressions.json @@ -1683,7 +1683,7 @@ "count": 8 }, "typescript/no-unsafe-member-access": { - "count": 9 + "count": 8 } }, "src/view/com/util/EmptyState.tsx": { diff --git a/src/components/moderation/ReportDialog/utils/reportSubject.ts b/src/components/moderation/ReportDialog/utils/reportSubject.ts index a639323b9b..a4bef9f43a 100644 --- a/src/components/moderation/ReportDialog/utils/reportSubject.ts +++ b/src/components/moderation/ReportDialog/utils/reportSubject.ts @@ -2,9 +2,10 @@ import {type com} from '#/lexicons' /** * The `subject` union of the generated `createReport` input body. The lexicon - * declares only `com.atproto.admin.defs#repoRef` and `com.atproto.repo.strongRef` - * with branded string fields (`did: l.DidString`, `uri: l.AtUriString`, - * `cid: l.CidString`). + * declares only `com.atproto.admin.defs#repoRef` and `com.atproto.repo.strongRef`. + * `did`/`uri` are branded string types (`l.DidString`, `l.AtUriString`); `cid` + * is typed `l.CidString`, which is a plain (unbranded) `string` alias, so only + * the former two need assertions below. */ type ReportSubject = com.atproto.moderation.createReport.$InputBody['subject'] @@ -14,7 +15,7 @@ type RepoRefSubject = Extract< {$type: 'com.atproto.admin.defs#repoRef'} > -/** The strongRef arm of the subject union, carrying the branded `uri`/`cid`. */ +/** The strongRef arm of the subject union, carrying the branded `uri`. */ type StrongRefSubject = Extract< ReportSubject, {$type: 'com.atproto.repo.strongRef'} @@ -33,8 +34,8 @@ export function accountReportSubject(did: string): ReportSubject { /** * Branded strongRef subject from plain uri/cid strings. The app holds these as - * plain strings; brand `uri` to the lexicon's `uri` slot (`cid` is a plain - * string in the generated type, so it needs no assertion). + * plain strings; brand `uri` to the lexicon's `uri` slot (`l.CidString` is an + * unbranded `string` alias, so `cid` needs no assertion). */ export function recordReportSubject(uri: string, cid: string): ReportSubject { return { diff --git a/src/view/com/posts/PostFeedErrorMessage.tsx b/src/view/com/posts/PostFeedErrorMessage.tsx index d51c9a0161..bf545633f7 100644 --- a/src/view/com/posts/PostFeedErrorMessage.tsx +++ b/src/view/com/posts/PostFeedErrorMessage.tsx @@ -9,7 +9,7 @@ import {useNavigation} from '@react-navigation/native' import {usePalette} from '#/lib/hooks/usePalette' import {type NavigationProp} from '#/lib/routes/types' import {cleanError} from '#/lib/strings/errors' -import {getErrorName} from '#/lib/xrpc-error' +import {getErrorName, getErrorStatus} from '#/lib/xrpc-error' import {logger} from '#/logger' import {type FeedDescriptor} from '#/state/queries/post-feed' import {useRemoveFeedMutation} from '#/state/queries/preferences' @@ -247,7 +247,7 @@ function detectKnownError( } // check status codes - if (error?.status === 429) { + if (getErrorStatus(error) === 429) { return KnownError.FeedTooManyRequests }