def get_app_version_info(domain, build_id, xform_version, xform_metadata):
    appversion_text = get_meta_appversion_text(xform_metadata)
    commcare_version = get_commcare_version_from_appversion_text(appversion_text)
    build_version = get_version_from_build_id(domain, build_id)
    if build_version:
        return AppVersionInfo(build_version, commcare_version, BuildVersionSource.BUILD_ID)

    build_version = get_version_from_appversion_text(appversion_text)
    if build_version:
        return AppVersionInfo(build_version, commcare_version, BuildVersionSource.APPVERSION_TEXT)

    if xform_version and xform_version != '1':
        return AppVersionInfo(int(xform_version), commcare_version, BuildVersionSource.XFORM_VERSION)

    return AppVersionInfo(None, commcare_version, BuildVersionSource.NONE)
there are a bunch of unreliable places to look for a build version
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/receiverwrapper/util.py/get_app_version_info