{"record":{"id":"9ebb26be3489873c","repo":"Budibase/budibase","slug":"slack-app-configuration-requires-a-development-wor","errorCode":null,"errorMessage":"Slack app configuration requires a development workspace","messagePattern":"Slack app configuration requires a development workspace","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/slackAppConfig.ts","lineNumber":23,"sourceCode":"  HTTPError,\n} from \"@budibase/backend-core\"\nimport {\n  DocumentType,\n  PASSWORD_REPLACEMENT,\n  SEPARATOR,\n  type SlackAppConfig,\n} from \"@budibase/types\"\nimport { rotateSlackConfigToken } from \"./deployments/slack\"\n\nconst SECRET_ENCODING_PREFIX = \"bbai_enc::\"\nconst TOKEN_EXPIRY_BUFFER_MS = 5 * 60 * 1000\n\nconst SLACK_APP_CONFIG_ID = `${DocumentType.SLACK_APP_CONFIG}${SEPARATOR}config`\n\nconst getWorkspaceDB = () => {\n  const workspaceId = context.getWorkspaceId()\n  if (!workspaceId || !dbCore.isDevWorkspaceID(workspaceId)) {\n    throw new HTTPError(\n      \"Slack app configuration requires a development workspace\",\n      400\n    )\n  }\n  return context.getWorkspaceDB()\n}\n\nconst encodeSecret = (value: string): string => {\n  if (!value || value.startsWith(SECRET_ENCODING_PREFIX)) {\n    return value\n  }\n  return `${SECRET_ENCODING_PREFIX}${encryption.encrypt(value)}`\n}\n\nconst decodeSecret = (value: string): string => {\n  if (!value || !value.startsWith(SECRET_ENCODING_PREFIX)) {\n    return value\n  }","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/slackAppConfig.ts#L5-L41","documentation":"Slack app configuration is stored inside the dev workspace's database. getWorkspaceDB reads the workspace id from the request context and throws this 400 HTTPError when there is no workspace id in context or the workspace is not a development workspace (prod apps/published workspaces cannot hold Slack app config).","triggerScenarios":"Calling any Slack app config operation (fetch, save, fetchConfigToken, remove) from a context without a workspace id, or while targeting a published/production workspace instead of a dev one.","commonSituations":"Calling the API outside an app workspace context (e.g. from a global endpoint or script); operating on a published app instead of the dev copy; missing workspace header/route param so context is empty; automation or job running without workspace context.","solutions":["Invoke the Slack config APIs within a development workspace context (open the app in the builder / use the dev app id)","Pass the correct dev workspace (appId) header/param in the request","Do not manage Slack app config on published/prod apps — configure it in the dev app and deploy","If running in a script/job, set the workspace context explicitly before calling (context.doInWorkspace)"],"exampleFix":"// before\nawait slackAppConfig.save(token, refreshToken) // no workspace context\n// after\nawait context.doInWorkspace(devWorkspaceId, async () =>\n  slackAppConfig.save(token, refreshToken)\n)","handlingStrategy":"validation","validationCode":"import { context, db as dbCore } from \"@budibase/backend-core\"\nconst workspaceId = context.getWorkspaceId()\nif (!workspaceId || !dbCore.isDevWorkspaceID(workspaceId)) {\n  throw new Error(\"Slack app config APIs require a dev workspace context\")\n}","typeGuard":"const isInDevWorkspace = (): boolean => {\n  const id = context.getWorkspaceId()\n  return !!id && dbCore.isDevWorkspaceID(id)\n}","tryCatchPattern":"try {\n  await slackAppConfig.fetch()\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 400 && err.message.includes(\"development workspace\")) {\n    // redirect to dev workspace / set workspace context\n  } else { throw err }\n}","preventionTips":["Only call Slack config APIs from workspace-scoped (dev app) routes","Never manage Slack config on published/prod apps","Explicitly set workspace context in scripts via context.doInWorkspace","Check context.getWorkspaceId() early in request handlers"],"tags":["slack","workspace-context","configuration"],"backgroundTag":"wrong-environment-context","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}