{"record":{"id":"49b88c28450c3500","repo":"Budibase/budibase","slug":"knowledge-base-file-does-not-have-an-object-key","errorCode":null,"errorMessage":"Knowledge base file does not have an object key","messagePattern":"Knowledge base file does not have an object key","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/knowledgeBase/uploads.ts","lineNumber":225,"sourceCode":"        error?.message || \"Failed to enqueue file for processing\"\n      await updateKnowledgeBaseFile(file)\n      console.error(\"Failed to enqueue knowledge base file during reset\", {\n        workspaceId,\n        knowledgeBaseId,\n        fileId: file._id,\n        error,\n      })\n    }\n  }\n}\n\nexport const retryKnowledgeBaseFileIngestion = async (fileId: string) => {\n  const workspaceId = context.getOrThrowWorkspaceId()\n  const file = await getKnowledgeBaseFileOrThrow(fileId)\n  const startedAtMs = Date.now()\n\n  if (!file.objectStoreKey) {\n    throw new HTTPError(\"Knowledge base file does not have an object key\", 400)\n  }\n  if (file.status !== KnowledgeBaseFileStatus.FAILED) {\n    throw new HTTPError(\"Knowledge base file is not in failed state\", 400)\n  }\n\n  file.status = KnowledgeBaseFileStatus.PROCESSING\n  file.errorMessage = undefined\n  file.processedAt = undefined\n  await updateKnowledgeBaseFile(file)\n  console.log(\"Retrying knowledge base file ingestion\", {\n    workspaceId,\n    knowledgeBaseId: file.knowledgeBaseId,\n    fileId,\n    objectStoreKey: file.objectStoreKey,\n  })\n\n  try {\n    await enqueueRagFileIngestion({","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/knowledgeBase/uploads.ts#L207-L243","documentation":"retryKnowledgeBaseFileIngestion re-enqueues ingestion for a failed knowledge base file. To reprocess the file it needs the object store key (the path of the uploaded file in the APPS bucket). If the file record has no objectStoreKey there is nothing to re-ingest, so a 400 HTTPError is thrown.","triggerScenarios":"Calling retryKnowledgeBaseFileIngestion(fileId) where the stored KnowledgeBaseFile document lacks objectStoreKey — e.g. the record was created before the upload step completed, or the upload failed and the key was never assigned.","commonSituations":"Retrying ingestion for a file whose original upload errored out (the upload path deletes the object but may leave a record without a usable key), or manually created/corrupted file records in the workspace DB.","solutions":["Re-upload the file via the normal knowledge base upload endpoint so a fresh record with objectStoreKey is created, instead of retrying.","Check the file document in the workspace DB — if objectStoreKey is genuinely absent the file cannot be retried.","Only call retry for files that completed upload (uploadKnowledgeBaseFile succeeded) but failed during ingestion."],"exampleFix":"// before\nawait retryKnowledgeBaseFileIngestion(fileId) // file has no objectStoreKey\n// after\nconst file = await getKnowledgeBaseFileOrThrow(fileId)\nif (file.objectStoreKey) {\n  await retryKnowledgeBaseFileIngestion(fileId)\n} else {\n  await uploadKnowledgeBaseFile({ knowledgeBaseId: file.knowledgeBaseId, ... })\n}","handlingStrategy":"validation","validationCode":"const file = await getKnowledgeBaseFileOrThrow(fileId)\nif (!file.objectStoreKey) {\n  // cannot retry: re-upload instead\n  return reuploadKnowledgeBaseFile(file)\n}\nawait retryKnowledgeBaseFileIngestion(fileId)","typeGuard":"const isRetryableKnowledgeBaseFile = (\n  f: KnowledgeBaseFile\n): f is KnowledgeBaseFile & { objectStoreKey: string } =>\n  typeof f.objectStoreKey === \"string\" && f.objectStoreKey.length > 0","tryCatchPattern":"try {\n  await retryKnowledgeBaseFileIngestion(fileId)\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 400) {\n    // fall back to re-uploading the file\n  }\n  throw err\n}","preventionTips":["Only expose the retry action for files whose upload completed successfully.","Treat a missing objectStoreKey as terminal and offer re-upload in the UI instead of retry."],"tags":["validation","knowledge-base","object-store","http-400"],"backgroundTag":"missing-object-store-key","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}