Skip to content

Commit 6867281

Browse files
fix lint errors
1 parent 7eecb7a commit 6867281

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/web/src/actions.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { env } from "@/env.mjs";
44
import { ErrorCode } from "@/lib/errorCodes";
55
import { notAuthenticated, notFound, orgNotFound, secretAlreadyExists, ServiceError, ServiceErrorException, unexpectedError } from "@/lib/serviceError";
6-
import { CodeHostType, isServiceError } from "@/lib/utils";
6+
import { CodeHostType, isHttpError, isServiceError } from "@/lib/utils";
77
import { prisma } from "@/prisma";
88
import { render } from "@react-email/components";
99
import * as Sentry from '@sentry/nextjs';
@@ -851,14 +851,16 @@ export const experimental_addGithubRepositoryByUrl = async (repositoryUrl: strin
851851
repo,
852852
});
853853
githubRepo = response.data;
854-
} catch (error: any) {
855-
if (error.status === 404) {
854+
} catch (error) {
855+
if (isHttpError(error, 404)) {
856856
return {
857857
statusCode: StatusCodes.NOT_FOUND,
858858
errorCode: ErrorCode.INVALID_REQUEST_BODY,
859859
message: `Repository '${owner}/${repo}' not found or is private. Only public repositories can be added.`,
860860
} satisfies ServiceError;
861-
} else if (error.status === 403) {
861+
}
862+
863+
if (isHttpError(error, 403)) {
862864
return {
863865
statusCode: StatusCodes.FORBIDDEN,
864866
errorCode: ErrorCode.INVALID_REQUEST_BODY,
@@ -869,7 +871,7 @@ export const experimental_addGithubRepositoryByUrl = async (repositoryUrl: strin
869871
return {
870872
statusCode: StatusCodes.INTERNAL_SERVER_ERROR,
871873
errorCode: ErrorCode.INVALID_REQUEST_BODY,
872-
message: `Failed to fetch repository information: ${error.message || 'Unknown error'}`,
874+
message: `Failed to fetch repository information: ${error instanceof Error ? error.message : 'Unknown error'}`,
873875
} satisfies ServiceError;
874876
}
875877

packages/web/src/features/chat/components/chatThread/detailsCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Separator } from '@/components/ui/separator';
66
import { Skeleton } from '@/components/ui/skeleton';
77
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
88
import { cn } from '@/lib/utils';
9-
import { Brain, ChevronDown, ChevronRight, Clock, Cpu, InfoIcon, Loader2, List, ScanSearchIcon, Zap } from 'lucide-react';
9+
import { Brain, ChevronDown, ChevronRight, Clock, InfoIcon, Loader2, List, ScanSearchIcon, Zap } from 'lucide-react';
1010
import { MarkdownRenderer } from './markdownRenderer';
1111
import { FindSymbolDefinitionsToolComponent } from './tools/findSymbolDefinitionsToolComponent';
1212
import { FindSymbolReferencesToolComponent } from './tools/findSymbolReferencesToolComponent';

packages/web/src/lib/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,12 @@ export const getOrgMetadata = (org: Org): OrgMetadata | null => {
460460
return currentMetadata.success ? currentMetadata.data : null;
461461
}
462462

463-
export const IS_MAC = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
463+
export const IS_MAC = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
464+
465+
466+
export const isHttpError = (error: unknown, status: number): boolean => {
467+
return error !== null
468+
&& typeof error === 'object'
469+
&& 'status' in error
470+
&& error.status === status;
471+
}

0 commit comments

Comments
 (0)