Skip to content

Commit e3ae8c6

Browse files
committed
improvement(prefetch): skip the viewer proof when there is no session
Passing an empty-string userId ran a real permission query that could only return null. Take an optional userId instead and skip straight to the unauthorized path, matching how the home prefetch is called.
1 parent 0fa05c8 commit e3ae8c6

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

apps/sim/app/workspace/[workspaceId]/knowledge/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default async function KnowledgePage({
3434
* data-layer reads need to authorize against.
3535
*/
3636
const session = await getSession()
37-
await prefetchKnowledgeBases(queryClient, workspaceId, session?.user?.id ?? '')
37+
await prefetchKnowledgeBases(queryClient, workspaceId, session?.user?.id)
3838

3939
return (
4040
<HydrationBoundary state={dehydrate(queryClient)}>

apps/sim/app/workspace/[workspaceId]/knowledge/prefetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import { KNOWLEDGE_BASE_LIST_STALE_TIME, knowledgeKeys } from '@/hooks/queries/u
3030
export async function prefetchKnowledgeBases(
3131
queryClient: QueryClient,
3232
workspaceId: string,
33-
userId: string
33+
userId: string | undefined
3434
): Promise<void> {
35-
const hostContext = await getWorkspaceHostContextForViewer(workspaceId, userId)
35+
const hostContext = userId ? await getWorkspaceHostContextForViewer(workspaceId, userId) : null
3636

3737
await Promise.all([
3838
queryClient.prefetchQuery({

apps/sim/app/workspace/[workspaceId]/tables/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default async function TablesPage({ params }: { params: Promise<{ workspa
2727
* data-layer reads need to authorize against.
2828
*/
2929
const session = await getSession()
30-
await prefetchTables(queryClient, workspaceId, session?.user?.id ?? '')
30+
await prefetchTables(queryClient, workspaceId, session?.user?.id)
3131

3232
return (
3333
<HydrationBoundary state={dehydrate(queryClient)}>

apps/sim/app/workspace/[workspaceId]/tables/prefetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import { TABLE_LIST_STALE_TIME, tableKeys } from '@/hooks/queries/utils/table-ke
2929
export async function prefetchTables(
3030
queryClient: QueryClient,
3131
workspaceId: string,
32-
userId: string
32+
userId: string | undefined
3333
): Promise<void> {
34-
const hostContext = await getWorkspaceHostContextForViewer(workspaceId, userId)
34+
const hostContext = userId ? await getWorkspaceHostContextForViewer(workspaceId, userId) : null
3535

3636
await Promise.all([
3737
queryClient.prefetchQuery({

0 commit comments

Comments
 (0)