Revert "Deprecate http.server_host option and raise issue if used" (#155834)

This commit is contained in:
Erik Montnemery
2025-11-05 11:26:14 +01:00
committed by GitHub
parent 533b9f969d
commit 52a751507a
4 changed files with 4 additions and 105 deletions

View File

@@ -38,7 +38,6 @@ from homeassistant.const import (
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, issue_registry as ir, storage
from homeassistant.helpers.hassio import is_hassio
from homeassistant.helpers.http import (
KEY_ALLOW_CONFIGURED_CORS,
KEY_AUTHENTICATED, # noqa: F401
@@ -108,10 +107,9 @@ _DEFAULT_BIND = ["0.0.0.0", "::"] if _HAS_IPV6 else ["0.0.0.0"]
HTTP_SCHEMA: Final = vol.All(
cv.deprecated(CONF_BASE_URL),
cv.deprecated(CONF_SERVER_HOST), # Deprecated in HA Core 2025.11
vol.Schema(
{
vol.Optional(CONF_SERVER_HOST): vol.All(
vol.Optional(CONF_SERVER_HOST, default=_DEFAULT_BIND): vol.All(
cv.ensure_list, vol.Length(min=1), [cv.string]
),
vol.Optional(CONF_SERVER_PORT, default=SERVER_PORT): cv.port,
@@ -209,24 +207,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
if conf is None:
conf = cast(ConfData, HTTP_SCHEMA({}))
if CONF_SERVER_HOST in conf:
if is_hassio(hass):
issue_id = "server_host_deprecated_hassio"
severity = ir.IssueSeverity.ERROR
else:
issue_id = "server_host_deprecated"
severity = ir.IssueSeverity.WARNING
ir.async_create_issue(
hass,
DOMAIN,
issue_id,
breaks_in_ha_version="2026.5.0",
is_fixable=False,
severity=severity,
translation_key=issue_id,
)
server_host = conf.get(CONF_SERVER_HOST, _DEFAULT_BIND)
server_host = conf[CONF_SERVER_HOST]
server_port = conf[CONF_SERVER_PORT]
ssl_certificate = conf.get(CONF_SSL_CERTIFICATE)
ssl_peer_certificate = conf.get(CONF_SSL_PEER_CERTIFICATE)

View File

@@ -1,13 +1,5 @@
{
"issues": {
"server_host_deprecated": {
"description": "The `server_host` configuration option in the HTTP integration is deprecated and will be removed in a future release.\n\nIf you are using this option to bind Home Assistant to specific network interfaces, please remove it from your configuration. Home Assistant will automatically bind to all available interfaces by default.\n\nIf you have specific networking requirements, consider using firewall rules or other network configuration to control access to Home Assistant.",
"title": "The `server_host` HTTP configuration option is deprecated"
},
"server_host_deprecated_hassio": {
"description": "The deprecated `server_host` configuration option in the HTTP integration is prone to break the communication between Home Assistant Core and supervisor, and will be removed in a future release.\n\nIf you are using this option to bind Home Assistant to specific network interfaces, please remove it from your configuration. Home Assistant will automatically bind to all available interfaces by default.\n\nIf you have specific networking requirements, consider using firewall rules or other network configuration to control access to Home Assistant.",
"title": "The `server_host` HTTP configuration may break Home Assistant Core - Supervisor communication"
},
"ssl_configured_without_configured_urls": {
"description": "Home Assistant detected that SSL has been set up on your instance, however, no custom external internet URL has been set.\n\nThis may result in unexpected behavior. Text-to-speech may fail, and integrations may not be able to connect back to your instance correctly.\n\nTo address this issue, go to Settings > System > Network; under the \"Home Assistant URL\" section, configure your new \"Internet\" and \"Local network\" addresses that match your new SSL configuration.",
"title": "SSL is configured without an external URL or internal URL"

View File

@@ -7,7 +7,7 @@ from http import HTTPStatus
from ipaddress import ip_network
import logging
from pathlib import Path
from unittest.mock import ANY, Mock, patch
from unittest.mock import Mock, patch
import pytest
@@ -667,78 +667,3 @@ async def test_ssl_issue_urls_configured(
"http",
"ssl_configured_without_configured_urls",
) not in issue_registry.issues
@pytest.mark.parametrize(
(
"hassio",
"http_config",
"expected_serverhost",
"expected_warning_count",
"expected_issues",
),
[
(False, {}, ["0.0.0.0", "::"], 0, set()),
(
False,
{"server_host": "0.0.0.0"},
["0.0.0.0"],
1,
{("http", "server_host_deprecated")},
),
(True, {}, ["0.0.0.0", "::"], 0, set()),
(
True,
{"server_host": "0.0.0.0"},
[
"0.0.0.0",
],
1,
{("http", "server_host_deprecated_hassio")},
),
],
)
async def test_server_host(
hass: HomeAssistant,
hassio: bool,
issue_registry: ir.IssueRegistry,
http_config: dict,
expected_serverhost: list,
expected_warning_count: int,
expected_issues: set[tuple[str, str]],
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test server_host behavior."""
mock_server = Mock()
with (
patch("homeassistant.components.http.is_hassio", return_value=hassio),
patch(
"asyncio.BaseEventLoop.create_server", return_value=mock_server
) as mock_create_server,
):
assert await async_setup_component(
hass,
"http",
{"http": http_config},
)
await hass.async_start()
await hass.async_block_till_done()
mock_create_server.assert_called_once_with(
ANY,
expected_serverhost,
8123,
ssl=None,
backlog=128,
reuse_address=None,
reuse_port=None,
)
assert (
caplog.text.count(
"The 'server_host' option is deprecated, please remove it from your configuration"
)
== expected_warning_count
)
assert set(issue_registry.issues) == expected_issues

View File

@@ -137,6 +137,7 @@ def test_secrets() -> None:
"server_port": 8123,
"ssl_profile": "modern",
"use_x_frame_options": True,
"server_host": ["0.0.0.0", "::"],
}
assert res["secret_cache"] == {
get_test_config_dir("secrets.yaml"): {"http_pw": "http://google.com"}