Budibase/budibase · error · HTTPError
Unable to allocate Teams app package version
Error message
Unable to allocate Teams app package version
What it means
After a semver bump, the function attempts to persist the new app package version by calling sdk.ai.agents.update inside a retry loop over deployment targets. If every attempt fails (caught errors lead to 'continue') and the loop is exhausted, the function throws this 409 HTTPError indicating it could not allocate a Teams app package version.
Source
Thrown at packages/server/src/api/controllers/ai/agents.ts:311
...agent,
MSTeamsIntegration: {
...agent.MSTeamsIntegration,
appPackageVersion,
},
})
return { agent: updatedAgent, messagingEndpointUrl, appPackageVersion }
} catch (error) {
if (
db.isDocumentConflictError(error) &&
attempt < TEAMS_APP_PACKAGE_VERSION_RETRIES - 1
) {
continue
}
throw error
}
}
throw new HTTPError("Unable to allocate Teams app package version", 409)
}
export async function fetchTools(ctx: UserCtx<void, ToolMetadata[]>) {
ctx.body = await sdk.ai.agents.getAvailableToolsMetadata()
}
export async function fetchAgents(ctx: UserCtx<void, FetchAgentsResponse>) {
const agents = await sdk.ai.agents.fetch()
ctx.body = { agents: agents.map(toAgentResponse) }
}
export async function createAgent(
ctx: UserCtx<CreateAgentRequest, CreateAgentResponse>
) {
const body = ctx.request.body
const createdBy = ctx.user?._id!
const globalId = db.getGlobalIDFromUserMetadataID(createdBy)
const projectIds = await resolveProjectIds(body.projectIds)View on GitHub (pinned to a81a902e9a)
Solutions
- Retry the operation — the 409 signals a conflict, likely a concurrent deployment of the same agent
- Ensure only one deployment per agent runs at a time (serialize at the caller, add a lock)
- Check server logs for the underlying error from sdk.ai.agents.update that caused every iteration to fail
- Verify the agent still exists and MSTeamsIntegration is intact, then redeploy
Defensive patterns
Strategy: retry
Validate before calling
// Ensure no concurrent deployment is in flight for this agent before calling
const lockKey = `teams-deploy:${agent._id}`
if (await cache.get(lockKey)) throw new Error("A Teams deployment is already in progress for this agent")
await cache.store(lockKey, true, { ttl: 60 }) Try / catch
try {
await allocateMSTeamsAppPackageVersion({ agent, messagingEndpointUrl })
} catch (err) {
if (err instanceof HTTPError && err.status === 409) {
// wait for the competing deployment to finish, then retry once
await new Promise(r => setTimeout(r, 2000))
await allocateMSTeamsAppPackageVersion({ agent, messagingEndpointUrl })
} else { throw err }
} Prevention
- Serialize deployments per agent with a lock or queue
- Avoid triggering Teams deployment from multiple places concurrently
- Log the underlying sdk.ai.agents.update errors inside the loop for diagnosability
- Back off and retry 409s with jitter
When it happens
Trigger: All iterations of the update loop fail — e.g. concurrent updates from multiple calls racing on the same agent, sdk.ai.agents.update throwing repeatedly (conflict/optimistic-locking or API failure), then control falls past the loop to the final throw.
Common situations: Two users/automations deploying the Teams app for the same agent simultaneously; transient CouchDB write conflicts during every retry; agent document deleted mid-loop.
Related errors
- Invalid Teams app package version
- Failed to clear project assignments.
- Unable to bulk remove documents: ${res.error}
- Unable to remove top level directory - some skeleton files a
- Group name "${name}" is unavailable
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/d0da3ef50319d2ba.
Report an issue: GitHub.