From a3d9c5af7ee384381e4f72b0be577406c37d063e Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Thu, 9 Apr 2026 00:08:23 +0700 Subject: [PATCH] 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 --- autogpt_platform/backend/backend/data/graph.py | 2 +- autogpt_platform/backend/backend/data/graph_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/data/graph.py b/autogpt_platform/backend/backend/data/graph.py index 584a929e13..46099e8122 100644 --- a/autogpt_platform/backend/backend/data/graph.py +++ b/autogpt_platform/backend/backend/data/graph.py @@ -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): diff --git a/autogpt_platform/backend/backend/data/graph_test.py b/autogpt_platform/backend/backend/data/graph_test.py index 3c4ad15c2b..2064e6a9a3 100644 --- a/autogpt_platform/backend/backend/data/graph_test.py +++ b/autogpt_platform/backend/backend/data/graph_test.py @@ -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, {}))