fix(config): report computed fields as read-only on update (#1454)

PUT /v1/config/{path} answered "does not exist in model" when the
target was a computed field such as eos_device_instruction_entity_ids.
Raise an explicit read-only error instead, so API clients can tell
read-only fields from unknown ones.

Closes #913
This commit is contained in:
YTM-21
2026-10-26 07:16:16 +01:00
committed by GitHub
parent 58b968562e
commit 8f4fa6fe94
4 changed files with 35 additions and 1 deletions
+12
View File
@@ -486,6 +486,18 @@ def test_set_nested_key(path, value, expected, exception, config_eos):
f"Expected exception {exception}, but got {type(e)}: {e}"
)
def test_set_nested_key_read_only_computed_field(config_eos):
"""Setting a computed field is reported as read-only, not as missing."""
path = "adapter/homeassistant/eos_device_instruction_entity_ids"
with pytest.raises(TypeError, match="read-only computed field"):
config_eos.set_nested_value(path, ["sensor.eos_battery1"])
def test_set_nested_key_unknown_field_still_reports_missing(config_eos):
"""A field that does not exist keeps the original 'does not exist' message."""
with pytest.raises(TypeError, match="does not exist in model"):
config_eos.set_nested_value("adapter/homeassistant/no_such_field", 1)
@pytest.mark.parametrize(
"path, expected_value, exception",