mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[F118] coerce a lone-string where_to_look into a list
where_to_look is a list-typed handoff field like consequences/next_steps but was the only one NOT in the _wrap_scalar_in_list field_validator. A well-intentioned where_to_look='src/api/' 422'd at the route with no remediation envelope, and the agent's retry loop tripped the do-server circuit breaker — the exact failure mode the other list fields were hardened against. Add it to the mode='before' validator so a lone string is wrapped into a one-element list before type coercion.
This commit is contained in:
@@ -91,7 +91,9 @@ class NoteRequest(BaseModel):
|
|||||||
# 422'd at the route and the agent's retry loop tripped the circuit
|
# 422'd at the route and the agent's retry loop tripped the circuit
|
||||||
# breaker. ``mode="before"`` runs ahead of type coercion so
|
# breaker. ``mode="before"`` runs ahead of type coercion so
|
||||||
# the wrapped value satisfies the declared ``list[...]`` type.
|
# the wrapped value satisfies the declared ``list[...]`` type.
|
||||||
@field_validator("options", "consequences", "next_steps", mode="before")
|
@field_validator(
|
||||||
|
"options", "consequences", "next_steps", "where_to_look", mode="before"
|
||||||
|
)
|
||||||
@classmethod
|
@classmethod
|
||||||
def _wrap_scalar_in_list(cls, value: Any) -> Any:
|
def _wrap_scalar_in_list(cls, value: Any) -> Any:
|
||||||
return _coerce_to_list(value)
|
return _coerce_to_list(value)
|
||||||
|
|||||||
@@ -116,6 +116,18 @@ def test_note_request_coerces_string_next_steps_to_list() -> None:
|
|||||||
assert req.next_steps == ["wait for QA"]
|
assert req.next_steps == ["wait for QA"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_note_request_coerces_string_where_to_look_to_list() -> None:
|
||||||
|
"""F118: a single string for where_to_look is wrapped into a one-element
|
||||||
|
list. It is a list-typed handoff field like consequences/next_steps and
|
||||||
|
must tolerate a lone scalar — without this a well-intentioned
|
||||||
|
``where_to_look="src/api/"`` 422'd at the route (no remediation envelope)
|
||||||
|
and the agent's retry loop tripped the do-server circuit breaker."""
|
||||||
|
req = NoteRequest.model_validate(
|
||||||
|
{"text": "x", "scope": "handoff", "where_to_look": "src/api/auth.py"}
|
||||||
|
)
|
||||||
|
assert req.where_to_look == ["src/api/auth.py"]
|
||||||
|
|
||||||
|
|
||||||
def test_note_request_coerces_single_option_dict_to_list() -> None:
|
def test_note_request_coerces_single_option_dict_to_list() -> None:
|
||||||
"""A single option dict (not wrapped in a list) is wrapped into a list."""
|
"""A single option dict (not wrapped in a list) is wrapped into a list."""
|
||||||
req = NoteRequest.model_validate(
|
req = NoteRequest.model_validate(
|
||||||
|
|||||||
Reference in New Issue
Block a user