{"record":{"id":"428b10d20acbab77","repo":"Budibase/budibase","slug":"datasourceid-and-authconfigid-are-required","errorCode":null,"errorMessage":"datasourceId and authConfigId are required","messagePattern":"datasourceId and authConfigId are required","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/ai/files.ts","lineNumber":298,"sourceCode":"  const url = await sdk.ai.rag.getFileUrlForOperation(\n    agentId,\n    operationId,\n    fileId\n  )\n  ctx.body = { url }\n  ctx.status = 200\n}\n\nexport async function fetchAgentKnowledgeSourceOptions(\n  ctx: UserCtx<\n    void,\n    FetchAgentKnowledgeSourceOptionsResponse,\n    { datasourceId: string; authConfigId: string }\n  >\n) {\n  const { datasourceId, authConfigId } = ctx.params\n  if (!datasourceId || !authConfigId) {\n    throw new HTTPError(\"datasourceId and authConfigId are required\", 400)\n  }\n  ctx.body = {\n    options: await fetchSharePointSitesByDatasourceAuthConfig(\n      datasourceId,\n      authConfigId\n    ),\n  }\n  ctx.status = 200\n}\n\nexport async function fetchAgentKnowledgeSourceEntries(\n  ctx: UserCtx<\n    void,\n    FetchAgentKnowledgeSourceEntriesResponse,\n    { agentId: string; operationId: string }\n  >\n) {\n  const { agentId, operationId } = ctx.params","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/ai/files.ts#L280-L316","documentation":"Thrown by fetchAgentKnowledgeSourceOptions with HTTP 400 when either the datasourceId or authConfigId path parameter is missing or empty. Both are required to look up the SharePoint sites configured for a datasource auth credential.","triggerScenarios":"Calling the SharePoint site-options endpoint without both params in the path; empty string params from unconfigured datasource state; malformed route usage omitting one of the two segments.","commonSituations":"Frontend navigating to the site picker before the datasource/auth config is saved; URL built by concatenation with an undefined ID; integration setup incomplete so authConfigId does not exist yet.","solutions":["Resolve both datasourceId and authConfigId from the datasource configuration before calling.","URL-encode path params and avoid passing empty strings for unset IDs.","Complete the datasource auth configuration first, then fetch options.","Log the full request URL to confirm both segments are present."],"exampleFix":"// before\nawait api.get(`/ai/knowledge-sources/options/${dsId}/${authId ?? \"\"}`)\n// after\nif (!dsId || !authId) throw new Error(\"datasourceId and authConfigId are required\")\nawait api.get(`/ai/knowledge-sources/options/${encodeURIComponent(dsId)}/${encodeURIComponent(authId)}`)","handlingStrategy":"validation","validationCode":"if (!datasourceId || !authConfigId) throw new Error(\"datasourceId and authConfigId are required\")\nconst res = await api.getKnowledgeSourceOptions({ datasourceId, authConfigId })","typeGuard":null,"tryCatchPattern":"try {\n  const { options } = await api.getKnowledgeSourceOptions({ datasourceId, authConfigId })\n} catch (err) {\n  if (err.status === 400 && err.message.includes(\"datasourceId\")) {\n    // fix route params before retrying\n  } else throw err\n}","preventionTips":["Always resolve both datasourceId and authConfigId from the datasource config before calling.","URL-encode path params and avoid empty strings from unset state.","Disable the SharePoint picker UI until both IDs are known.","Log the request URL when integration setup is incomplete."],"tags":["http-400","validation","missing-parameter","sharepoint"],"backgroundTag":"missing-required-parameter","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}