File tree Expand file tree Collapse file tree
apps/sim/app/api/knowledge/[id]/documents Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,19 +164,19 @@ export const POST = withRouteHandler(
164164
165165 const kbWorkspaceId = accessCheck . knowledgeBase ?. workspaceId
166166
167- // Gate KB indexing (pooled + per-member) before accepting work. The
168- // authoritative backstop also runs in processDocumentAsync for non-HTTP
169- // paths (connector/cron/retry).
170- if ( kbWorkspaceId ) {
171- const usage = await checkActorUsageLimits ( userId , kbWorkspaceId )
172- if ( usage . isExceeded ) {
173- return NextResponse . json (
174- {
175- error : usage . message || 'Usage limit exceeded. Please upgrade your plan to continue.' ,
176- } ,
177- { status : 402 }
178- )
179- }
167+ // Gate KB indexing (pooled + per-member) before accepting work. Runs even for
168+ // legacy KBs with no workspace — the uploader's pooled/frozen status is still
169+ // enforced (per-member is simply skipped when there's no org workspace). The
170+ // authoritative backstop also runs in processDocumentAsync for non-HTTP paths
171+ // (connector/cron/retry).
172+ const usage = await checkActorUsageLimits ( userId , kbWorkspaceId )
173+ if ( usage . isExceeded ) {
174+ return NextResponse . json (
175+ {
176+ error : usage . message || 'Usage limit exceeded. Please upgrade your plan to continue.' ,
177+ } ,
178+ { status : 402 }
179+ )
180180 }
181181
182182 if ( body . bulk === true ) {
Original file line number Diff line number Diff line change @@ -74,18 +74,18 @@ export const POST = withRouteHandler(
7474 }
7575
7676 // Gate usage before any create/delete so an over-limit upsert is rejected up
77- // front and never deletes the existing (already-indexed) document.
77+ // front and never deletes the existing (already-indexed) document. Runs even
78+ // for legacy KBs with no workspace — the uploader's pooled/frozen status is
79+ // still enforced (per-member is skipped when there's no org workspace).
7880 const kbWorkspaceId = accessCheck . knowledgeBase ?. workspaceId
79- if ( kbWorkspaceId ) {
80- const usage = await checkActorUsageLimits ( userId , kbWorkspaceId )
81- if ( usage . isExceeded ) {
82- return NextResponse . json (
83- {
84- error : usage . message || 'Usage limit exceeded. Please upgrade your plan to continue.' ,
85- } ,
86- { status : 402 }
87- )
88- }
81+ const usage = await checkActorUsageLimits ( userId , kbWorkspaceId )
82+ if ( usage . isExceeded ) {
83+ return NextResponse . json (
84+ {
85+ error : usage . message || 'Usage limit exceeded. Please upgrade your plan to continue.' ,
86+ } ,
87+ { status : 402 }
88+ )
8989 }
9090
9191 let existingDocumentId : string | null = null
You can’t perform that action at this time.
0 commit comments