Repository: home-assistant/core
File: homeassistant/components/telegram_bot/__init__.py (Python)

Code before:
        service_call_origin = f"{origin.data[ATTR_DOMAIN]}.{origin.data[ATTR_SERVICE]}"

    ir.async_create_issue(
        hass,
        DOMAIN,
        "deprecated_timeout_parameter",
        breaks_in_ha_version="2026.7.0",
        is_fixable=True,
        is_persistent=True,
        severity=ir.IssueSeverity.WARNING,
        translation_key="deprecated_timeout_parameter",
        translation_placeholders={
            "integration_title": "Telegram Bot",
            "action": f"{DOMAIN}.{service.service}",
            "action_origin": service_call_origin,
        },
        learn_more_url="https://github.com/home-assistant/core/pull/155198",
    )


async def async_migrate_entry(
    hass: HomeAssistant, config_entry: TelegramBotConfigEntry
) -> bool:
    """Migrate Telegram Bot config entry."""

    # Minor version 2: add default API endpoint to data
    if not config_entry.data.get(CONF_API_ENDPOINT):
        new_data = {**config_entry.data}
        new_data[CONF_API_ENDPOINT] = DEFAULT_API_ENDPOINT
        updated = hass.config_entries.async_update_entry(
            config_entry, data=new_data, minor_version=2
        )
        _LOGGER.debug(
            "Migrated Telegram Bot config entry to minor version 2, entry updated: %s",
            updated,
        )

    return True


async def async_setup_entry(hass: HomeAssistant, entry: TelegramBotConfigEntry) -> bool:
    """Create the Telegram bot from config entry."""
    bot: Bot = await hass.async_add_executor_job(initialize_bot, hass, entry.data)
    try:
        await bot.get_me()
    except InvalidToken as err:
        raise ConfigEntryAuthFailed("Invalid API token for Telegram Bot.") from err
    except TelegramError as err:
        raise ConfigEntryNotReady from err

    p_type: str = entry.data[CONF_PLATFORM]

Review comment (suggestion):
```suggestion
    # Minor version 2: add default API endpoint to data
    if config_entry.version > 1:
        # This means the user has downgraded from a future version
        return False

    version = config_entry.version
    minor_version = config_entry.minor_version

    if version == 1 and minor_version == 1:
```
Let's add some guarding similar to above (you'll need to fix the indent)

Code after:
        service_call_origin = f"{origin.data[ATTR_DOMAIN]}.{origin.data[ATTR_SERVICE]}"

    ir.async_create_issue(
        hass,
        DOMAIN,
        "deprecated_timeout_parameter",
        breaks_in_ha_version="2026.7.0",
        is_fixable=True,
        is_persistent=True,
        severity=ir.IssueSeverity.WARNING,
        translation_key="deprecated_timeout_parameter",
        translation_placeholders={
            "integration_title": "Telegram Bot",
            "action": f"{DOMAIN}.{service.service}",
            "action_origin": service_call_origin,
        },
        learn_more_url="https://github.com/home-assistant/core/pull/155198",
    )


async def async_migrate_entry(
    hass: HomeAssistant, config_entry: TelegramBotConfigEntry
) -> bool:
    """Migrate Telegram Bot config entry."""

    version = config_entry.version
    minor_version = config_entry.minor_version
    _LOGGER.debug(
        "Migrating configuration from version %s.%s",
        version,
        minor_version,
    )

    if config_entry.version > 1:
        # This means the user has downgraded from a future version
        return False

    # version 1.1: to add default API endpoint
    if version == 1 and minor_version == 1:
        new_data = {**config_entry.data}
        new_data[CONF_API_ENDPOINT] = DEFAULT_API_ENDPOINT
        updated = hass.config_entries.async_update_entry(
            config_entry, data=new_data, minor_version=2
        )
        _LOGGER.debug(
            "Migrated Telegram Bot config entry to %s.%s, entry updated: %s",
            config_entry.version,
            config_entry.minor_version,
            updated,
        )