Documents
How is the default DBOS app version computed, and where is the method that computes it?
How is the default DBOS app version computed, and where is the method that computes it?
Type
Answer
Status
Published
Created
Jul 27, 2025
Updated
Mar 11, 2026
Created by
Dosu Bot
Updated by
Dosu Bot

The default DBOS app version is computed by the compute_app_version method in dbos/_dbos.py. This method generates an MD5 hash of the source code for all registered workflow functions (sorted for stability) and appends the DBOS framework version string.

The method includes graceful error handling: if it cannot retrieve workflow source code (e.g., when inspect.getsource() fails in certain deployment environments), it catches the exception and returns "DEFAULT_VERSION" as a fallback. A warning is logged: "Could not get workflow source code to compute an application version, defaulting application version to 'DEFAULT_VERSION'. Set a custom version through the 'application_version' field in DBOSConfig".

You can manually set a custom app version through the application_version field in DBOSConfig. This app version is distinct from the release version and only changes when your workflow code or the DBOS framework version changes, ensuring compatibility and recoverability.

The current application version is available via DBOS.application_version.

Application Version Management#

Application versions are automatically registered on startup with SystemDatabase.create_application_version(). The system maintains version metadata in the application_versions table, which tracks each version's unique identifier, name, and timestamp.

VersionInfo#

Version information is represented by the VersionInfo TypedDict with the following fields:

  • version_id (str): Unique identifier for the version
  • version_name (str): Human-readable version name
  • version_timestamp (int): Timestamp in milliseconds when the version was last set as latest
  • created_at (int): Timestamp in milliseconds when the version was first registered (immutable)

Note: The created_at field is immutable and set when a version is first registered on startup. The version_timestamp field is updated whenever set_latest_application_version is called to make that version the latest. This distinction allows tracking both when a version was created and when it was last promoted to latest.

DBOS Class Methods#

The DBOS class provides the following methods for managing application versions:

  • DBOS.list_application_versions() -> List[VersionInfo]: Returns all application versions ordered by timestamp descending
  • DBOS.get_latest_application_version() -> VersionInfo: Returns the latest application version (highest timestamp)
  • DBOS.set_latest_application_version(version_name: str) -> None: Sets a version as latest by updating its timestamp to the current time
  • DBOS.list_application_versions_async() -> List[VersionInfo]: Async version of list_application_versions
  • DBOS.get_latest_application_version_async() -> VersionInfo: Async version of get_latest_application_version
  • DBOS.set_latest_application_version_async(version_name: str) -> None: Async version of set_latest_application_version

DBOSClient Methods#

The same application version management methods are available on the DBOSClient class:

  • DBOSClient.list_application_versions() -> List[VersionInfo]
  • DBOSClient.get_latest_application_version() -> VersionInfo
  • DBOSClient.set_latest_application_version(version_name: str) -> None
  • DBOSClient.list_application_versions_async() -> List[VersionInfo]
  • DBOSClient.get_latest_application_version_async() -> VersionInfo
  • DBOSClient.set_latest_application_version_async(version_name: str) -> None

The latest version is determined by the highest version_timestamp value in the application_versions table. When set_latest_application_version is called, it updates the timestamp of the specified version to the current time, making it the latest version.