Budibase/budibase · error · HTTPError

Invalid Teams app package version

Error message

Invalid Teams app package version

What it means

allocateMSTeamsAppPackageVersion bumps the agent's MS Teams app package version using semver.inc on a patch increment. The current version is taken from agent.MSTeamsIntegration.appPackageVersion or falls back to INITIAL_TEAMS_APP_PACKAGE_VERSION. If semver.inc returns null (i.e. the stored version is not a valid semver string), the server throws this 500 HTTPError.

Source

Thrown at packages/server/src/api/controllers/ai/agents.ts:288

  ) {
    const agent = await sdk.ai.agents.getOrThrow(agentId)
    const messagingEndpointUrl =
      agent.MSTeamsIntegration?.messagingEndpointUrl?.trim()
    if (!messagingEndpointUrl) {
      throw new HTTPError(
        "Teams integration must be provisioned before downloading the app package",
        400
      )
    }

    sdk.ai.deployments.MSTeams.validateMSTeamsIntegration(agent)

    const currentVersion =
      agent.MSTeamsIntegration?.appPackageVersion ||
      INITIAL_TEAMS_APP_PACKAGE_VERSION
    const appPackageVersion = semver.inc(currentVersion, "patch")
    if (!appPackageVersion) {
      throw new HTTPError("Invalid Teams app package version", 500)
    }

    try {
      const updatedAgent = await sdk.ai.agents.update({
        ...agent,
        MSTeamsIntegration: {
          ...agent.MSTeamsIntegration,
          appPackageVersion,
        },
      })
      return { agent: updatedAgent, messagingEndpointUrl, appPackageVersion }
    } catch (error) {
      if (
        db.isDocumentConflictError(error) &&
        attempt < TEAMS_APP_PACKAGE_VERSION_RETRIES - 1
      ) {
        continue
      }

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Clear or fix agent.MSTeamsIntegration.appPackageVersion so it is a valid semver string (e.g. '1.0.0'), letting the code fall back to INITIAL_TEAMS_APP_PACKAGE_VERSION if it should start fresh
  2. Reset the field to INITIAL_TEAMS_APP_PACKAGE_VERSION via a script/API update on the agent document
  3. Ensure INITIAL_TEAMS_APP_PACKAGE_VERSION in the codebase is a valid full semver triple
  4. Check for migration/import code that wrote a non-semver value into MSTeamsIntegration

Example fix

// before
agent.MSTeamsIntegration.appPackageVersion = "1.0"
// after
agent.MSTeamsIntegration.appPackageVersion = "1.0.0"
Defensive patterns

Strategy: validation

Validate before calling

import semver from "semver"
const current = agent.MSTeamsIntegration?.appPackageVersion || INITIAL_TEAMS_APP_PACKAGE_VERSION
if (!semver.valid(current)) {
  throw new Error(`Stored Teams app package version is not valid semver: ${current}`)
}

Type guard

function isValidSemver(v: string | undefined): v is string {
  return typeof v === "string" && semver.valid(v) !== null
}

Try / catch

try {
  const version = await allocateMSTeamsAppPackageVersion({ agent, messagingEndpointUrl })
} catch (err) {
  if (err instanceof HTTPError && err.status === 500 && err.message.includes("Invalid Teams app package version")) {
    await sdk.ai.agents.update({ ...agent, MSTeamsIntegration: { ...agent.MSTeamsIntegration, appPackageVersion: INITIAL_TEAMS_APP_PACKAGE_VERSION } })
    // retry allocation
  } else { throw err }
}

Prevention

When it happens

Trigger: agent.MSTeamsIntegration.appPackageVersion exists but is a malformed/non-semver string (e.g. '1.0', 'v1.0.0-beta bad', free text) such that semver.inc(currentVersion, 'patch') returns null.

Common situations: A stored version was hand-edited in the database, migrated from a legacy format, or corrupted by an earlier deploy; INITIAL_TEAMS_APP_PACKAGE_VERSION constant itself mismatches what semver accepts after manual edits.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/63c96bab871e6dce. Report an issue: GitHub.