Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend): Mark ValueError as known block errors (#11537)

Zamil Majdy2f63defb533a
diff --git a/autogpt_platform/backend/backend/data/block.py b/autogpt_platform/backend/backend/data/block.py
index 315d63bd8f..727688dcf0 100644
--- a/autogpt_platform/backend/backend/data/block.py
+++ b/autogpt_platform/backend/backend/data/block.py
@@ -601,14 +601,18 @@ class Block(ABC, Generic[BlockSchemaInputType, BlockSchemaOutputType]):
async for output_name, output_data in self._execute(input_data, **kwargs):
yield output_name, output_data
except Exception as ex:
- if not isinstance(ex, BlockError):
- raise BlockUnknownError(
+ if isinstance(ex, BlockError):
+ raise ex
+ else:
+ raise (
+ BlockExecutionError
+ if isinstance(ex, ValueError)
+ else BlockUnknownError
+ )(
message=str(ex),
block_name=self.name,
block_id=self.id,
) from ex
- else:
- raise ex
async def _execute(self, input_data: BlockInput, **kwargs) -> BlockOutput:
if error := self.input_schema.validate_data(input_data):