|
1 | 1 | from pathlib import Path |
2 | 2 | from typing import List, Union, Optional, Literal, Any, Annotated, Type, TypeVar |
3 | | -from pydantic import BaseModel, Field, field_validator, field_serializer, model_validator |
| 3 | +from pydantic import BaseModel, Field, field_validator, field_serializer |
4 | 4 | from pydantic import ValidationError |
5 | 5 | import json |
6 | 6 | import logging |
@@ -83,13 +83,6 @@ class PythonWorkflowDefinitionEdge(BaseModel): |
83 | 83 | source: int |
84 | 84 | sourcePort: Optional[str] = None |
85 | 85 |
|
86 | | - @model_validator(mode='before') |
87 | | - @classmethod |
88 | | - def set_default_source_port(cls, data: Any) -> Any: |
89 | | - if isinstance(data, dict) and 'sourcePort' not in data: |
90 | | - data['sourcePort'] = None |
91 | | - return data |
92 | | - |
93 | 86 | @field_validator("sourcePort", mode="before") |
94 | 87 | @classmethod |
95 | 88 | def handle_default_source(cls, v: Any) -> Optional[str]: |
@@ -222,6 +215,9 @@ def load_json_str(cls: Type[T], json_data: Union[str, bytes]) -> dict: |
222 | 215 | except ValidationError: # Catch validation errors specifically |
223 | 216 | logger.error("Workflow model validation failed.", exc_info=True) |
224 | 217 | raise |
| 218 | + except json.JSONDecodeError: # Catch JSON parsing errors specifically |
| 219 | + logger.error("Invalid JSON format encountered.", exc_info=True) |
| 220 | + raise |
225 | 221 | except Exception as e: # Catch any other unexpected errors |
226 | 222 | logger.error( |
227 | 223 | f"An unexpected error occurred during JSON loading: {e}", exc_info=True |
|
0 commit comments