Skip to content

Commit d068f4e

Browse files
authored
Update models.py
1 parent 91d6723 commit d068f4e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/python_workflow_definition/models.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pathlib import Path
22
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
44
from pydantic import ValidationError
55
import json
66
import logging
@@ -83,13 +83,6 @@ class PythonWorkflowDefinitionEdge(BaseModel):
8383
source: int
8484
sourcePort: Optional[str] = None
8585

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-
9386
@field_validator("sourcePort", mode="before")
9487
@classmethod
9588
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:
222215
except ValidationError: # Catch validation errors specifically
223216
logger.error("Workflow model validation failed.", exc_info=True)
224217
raise
218+
except json.JSONDecodeError: # Catch JSON parsing errors specifically
219+
logger.error("Invalid JSON format encountered.", exc_info=True)
220+
raise
225221
except Exception as e: # Catch any other unexpected errors
226222
logger.error(
227223
f"An unexpected error occurred during JSON loading: {e}", exc_info=True

0 commit comments

Comments
 (0)