Skip to content

Commit d210669

Browse files
committed
fix(knowledge): use hardDeleteKnowledgeBase in cleanup path
1 parent f6d121e commit d210669

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

apps/sim/app/api/knowledge/route.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
import { getOllamaBaseUrl, validateOllamaModel } from '@/lib/knowledge/embeddings'
1414
import {
1515
createKnowledgeBase,
16-
deleteKnowledgeBase,
1716
getKnowledgeBases,
17+
hardDeleteKnowledgeBase,
1818
KnowledgeBaseConflictError,
1919
type KnowledgeBaseScope,
2020
} from '@/lib/knowledge/service'
@@ -221,10 +221,11 @@ export async function POST(req: NextRequest) {
221221
`[${requestId}] Failed to create embedding table for KB ${newKnowledgeBase.id}`,
222222
tableError
223223
)
224-
// Clean up the orphaned KB row and any partially-created table
224+
// Hard-delete the KB row — this is a creation-time rollback, not a user-initiated
225+
// deletion, so a soft delete would leave a restorable broken KB in the archive.
225226
try {
226227
await dropKBEmbeddingTable(newKnowledgeBase.id)
227-
await deleteKnowledgeBase(newKnowledgeBase.id, requestId)
228+
await hardDeleteKnowledgeBase(newKnowledgeBase.id)
228229
logger.info(
229230
`[${requestId}] Cleaned up orphaned KB ${newKnowledgeBase.id} after table creation failure`
230231
)

0 commit comments

Comments
 (0)