{"record":{"id":"63c96bab871e6dce","repo":"Budibase/budibase","slug":"invalid-teams-app-package-version","errorCode":null,"errorMessage":"Invalid Teams app package version","messagePattern":"Invalid Teams app package version","errorType":"http","errorClass":"HTTPError","httpStatus":500,"severity":"error","filePath":"packages/server/src/api/controllers/ai/agents.ts","lineNumber":288,"sourceCode":"  ) {\n    const agent = await sdk.ai.agents.getOrThrow(agentId)\n    const messagingEndpointUrl =\n      agent.MSTeamsIntegration?.messagingEndpointUrl?.trim()\n    if (!messagingEndpointUrl) {\n      throw new HTTPError(\n        \"Teams integration must be provisioned before downloading the app package\",\n        400\n      )\n    }\n\n    sdk.ai.deployments.MSTeams.validateMSTeamsIntegration(agent)\n\n    const currentVersion =\n      agent.MSTeamsIntegration?.appPackageVersion ||\n      INITIAL_TEAMS_APP_PACKAGE_VERSION\n    const appPackageVersion = semver.inc(currentVersion, \"patch\")\n    if (!appPackageVersion) {\n      throw new HTTPError(\"Invalid Teams app package version\", 500)\n    }\n\n    try {\n      const updatedAgent = await sdk.ai.agents.update({\n        ...agent,\n        MSTeamsIntegration: {\n          ...agent.MSTeamsIntegration,\n          appPackageVersion,\n        },\n      })\n      return { agent: updatedAgent, messagingEndpointUrl, appPackageVersion }\n    } catch (error) {\n      if (\n        db.isDocumentConflictError(error) &&\n        attempt < TEAMS_APP_PACKAGE_VERSION_RETRIES - 1\n      ) {\n        continue\n      }","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/ai/agents.ts#L270-L306","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Reset the field to INITIAL_TEAMS_APP_PACKAGE_VERSION via a script/API update on the agent document","Ensure INITIAL_TEAMS_APP_PACKAGE_VERSION in the codebase is a valid full semver triple","Check for migration/import code that wrote a non-semver value into MSTeamsIntegration"],"exampleFix":"// before\nagent.MSTeamsIntegration.appPackageVersion = \"1.0\"\n// after\nagent.MSTeamsIntegration.appPackageVersion = \"1.0.0\"","handlingStrategy":"validation","validationCode":"import semver from \"semver\"\nconst current = agent.MSTeamsIntegration?.appPackageVersion || INITIAL_TEAMS_APP_PACKAGE_VERSION\nif (!semver.valid(current)) {\n  throw new Error(`Stored Teams app package version is not valid semver: ${current}`)\n}","typeGuard":"function isValidSemver(v: string | undefined): v is string {\n  return typeof v === \"string\" && semver.valid(v) !== null\n}","tryCatchPattern":"try {\n  const version = await allocateMSTeamsAppPackageVersion({ agent, messagingEndpointUrl })\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 500 && err.message.includes(\"Invalid Teams app package version\")) {\n    await sdk.ai.agents.update({ ...agent, MSTeamsIntegration: { ...agent.MSTeamsIntegration, appPackageVersion: INITIAL_TEAMS_APP_PACKAGE_VERSION } })\n    // retry allocation\n  } else { throw err }\n}","preventionTips":["Never hand-edit appPackageVersion in the database; only let the allocator write it","Validate the version format when importing/migrating agents","Keep INITIAL_TEAMS_APP_PACKAGE_VERSION a full semver triple","Add a data-quality check that flags agents with non-semver MSTeamsIntegration.appPackageVersion"],"tags":["semver","versioning","msteams","server"],"backgroundTag":"invalid-semver-string","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}