Budibase/budibase · error · HTTPError
Knowledge base not found
Error message
Knowledge base not found
What it means
uploadKnowledgeBaseFile first resolves the target knowledge base via findKnowledgeBase(input.knowledgeBaseId); if no such knowledge base doc exists in the workspace DB, it throws HTTPError 404 before writing anything to object storage. This prevents orphaned files being uploaded to a non-existent KB.
Source
Thrown at packages/server/src/sdk/workspace/ai/knowledgeBase/uploads.ts:56
buffer: Buffer
uploadedBy: string
}
const buildKnowledgeBaseFileObjectStoreKey = (
workspaceId: string,
knowledgeBaseId: string,
fileId: string,
filename: string
) =>
`${workspaceId}/ai/knowledge-bases/${knowledgeBaseId}/files/${fileId}/${filename}`
export const uploadKnowledgeBaseFile = async (
input: UploadKnowledgeBaseFileInput
): Promise<KnowledgeBaseFile> => {
const workspaceId = context.getOrThrowWorkspaceId()
const knowledgeBase = await findKnowledgeBase(input.knowledgeBaseId)
if (!knowledgeBase) {
throw new HTTPError("Knowledge base not found", 404)
}
const fileId = docIds.generateKnowledgeBaseFileID(input.knowledgeBaseId)
const objectStoreKey = buildKnowledgeBaseFileObjectStoreKey(
workspaceId,
input.knowledgeBaseId,
fileId,
input.filename
)
const startedAtMs = Date.now()
console.log("Starting knowledge base file upload", {
workspaceId,
knowledgeBaseId: input.knowledgeBaseId,
fileId,
filename: input.filename,
mimetype: input.mimetype,
size: input.size ?? input.buffer.byteLength,
sourceType: input.source?.type,View on GitHub (pinned to a81a902e9a)
Solutions
- Verify the knowledgeBaseId exists (list knowledge bases or fetch it) before uploading
- Ensure the request carries the correct workspace/app context so context.getOrThrowWorkspaceId resolves the right DB
- If the KB was deleted, recreate it or discard the upload
- Correct any typo'd/mismatched knowledgeBaseId in the client call
Example fix
// before
await uploadKnowledgeBaseFile({ knowledgeBaseId: staleId, ... }) // 404
// after
const kbs = await sdk.ai.knowledgeBase.list()
if (!kbs.some(kb => kb._id === knowledgeBaseId)) throw new Error("Pick a valid KB")
await uploadKnowledgeBaseFile({ knowledgeBaseId, ... }) Defensive patterns
Strategy: validation
Validate before calling
import { find as findKnowledgeBase } from "./crud"
const kb = await findKnowledgeBase(knowledgeBaseId).catch(() => null)
if (!kb) throw new Error(`Knowledge base ${knowledgeBaseId} does not exist`) Try / catch
try {
await uploadKnowledgeBaseFile({ knowledgeBaseId, ... })
} catch (e) {
if (e instanceof HTTPError && e.status === 404) {
// prompt user to select/recreate a knowledge base
}
} Prevention
- Resolve KBs from the server list, never from stale client state
- Refresh KB selections after any delete
- Ensure requests carry the correct workspace/app context headers
When it happens
Trigger: Calling uploadKnowledgeBaseFile with a knowledgeBaseId that does not exist in the current workspace DB — wrong ID, deleted KB, or the request running against the wrong workspace context.
Common situations: Client kept a form open after the KB was deleted; ID copied from another app/workspace; missing or wrong workspace ID in request context so findKnowledgeBase looks in the wrong DB; typo in knowledgeBaseId in an API call.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Resource not found: ${body.resourceId}
- Operation not found for this agent
- Custom REST template not found
- Automation not found
- Webhook not found
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/56bf43694deb4084.
Report an issue: GitHub.