fix(backend): tighten ValueError message and test assertion in _generate_schema

- Add stable prefix to ValueError: "Invalid graph schema input: {e}"
  to aid debugging and triage
- Add match="name" to pytest.raises to guard the specific missing-name
  failure path, not just any ValueError
This commit is contained in:
Zamil Majdy
2026-04-09 00:08:23 +07:00
parent 50e4039cdd
commit a3d9c5af7e
2 changed files with 2 additions and 2 deletions

View File

@@ -355,7 +355,7 @@ class BaseGraph(GraphBaseMeta):
"required": [p.name for p in schema_fields if p.value is None],
}
except AttributeError as e:
raise ValueError(str(e)) from e
raise ValueError(f"Invalid graph schema input: {e}") from e
class GraphTriggerInfo(BaseModel):

View File

@@ -1477,5 +1477,5 @@ def test_generate_schema_raises_value_error_when_name_missing():
and re-raised as ValueError so the existing 400 handler in rest_api.py fires
instead of falling through to the 500 catch-all.
"""
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="name"):
GraphModel._generate_schema((AgentInputBlock.Input, {}))