mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-29 17:21:57 +00:00
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:
@@ -569,6 +569,11 @@ class PydanticModelNestedValueMixin:
|
||||
raise TypeError(f"Model '{model}' is not of class type.")
|
||||
|
||||
if key not in model.model_fields:
|
||||
if key in model.model_computed_fields:
|
||||
raise TypeError(
|
||||
f"Field '{key}' of model '{model.__name__}' is a read-only computed "
|
||||
"field and cannot be updated."
|
||||
)
|
||||
raise TypeError(f"Field '{key}' does not exist in model '{model.__name__}'.")
|
||||
|
||||
field_annotation = model.model_fields[key].annotation
|
||||
|
||||
Reference in New Issue
Block a user