Pydantic validation error occurs during AgentHeartbeatEvent deserialization
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Summary
Follow up issue of [https://lablup.atlassian.net/browse/BA-2404](https://lablup.atlassian.net/browse/BA-2404), [https://lablup.atlassian.net/browse/BA-2305](https://lablup.atlassian.net/browse/BA-2305) , [https://lablup.atlassian.net/browse/BA-3089](https://lablup.atlassian.net/browse/BA-3089)
If an Agent that has not applied 3089 sends a Heartbeat to a Manager that has applied 2305, a pydantic error occurs during the initialization of the `AgentInfo` object within the `AgentHeartbeatEvent`. The existing issue 3089 addressed a bug concerning the `AgentHeartbeatEvent` object being created on the Agent side, but failed to consider the deserialization of the `AgentHeartbeatEvent`. Fallback logic must be implemented to prevent this.
## Logs/Errors
```python
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: Traceback (most recent call last):
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: File "/home/bai/.static-python/venvs/bai-25.6-manager/lib/python3.13/site-packages/aiotools/taskgroup/persistent.py", line 171, in _task_wrapper
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: ret = await cast(Awaitable[T], coro) # forced cast for Python 3.12 or older
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: File "/home/bai/.static-python/venvs/bai-25.6-manager/lib/python3.13/site-packages/ai/backend/common/events/dispatcher.py", line 523, in _handle
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: event = event_cls.deserialize(args)
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: File "/home/bai/.static-python/venvs/bai-25.6-manager/lib/python3.13/site-packages/ai/backend/common/events/event_types/agent/anycast.py", line 126, in deserialize
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: return cls(AgentInfo.model_validate(value[0]))
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: File "/home/bai/.static-python/venvs/bai-25.6-manager/lib/python3.13/site-packages/pydantic/main.py", line 703, in model_validate
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: return cls.__pydantic_validator__.validate_python(
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: obj, strict=strict, from_attributes=from_attributes, context=context, by_alias=by_alias, by_name=by_name
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: )
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: ^
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: pydantic_core._pydantic_core.ValidationError: 2 validation errors for AgentInfo
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: slot_key_and_units.cpu.[key]
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: Input should be an instance of SlotName [type=is_instance_of, input_value='cpu', input_type=str]
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: For further information visit https://errors.pydantic.dev/2.11/v/is_instance_of
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: slot_key_and_units.mem.[key]
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: Input should be an instance of SlotName [type=is_instance_of, input_value='mem', input_type=str]
Nov 25 11:35:31 bai-mgr-01 run-manager.sh[174823]: For further information visit https://errors.pydantic.dev/2.11/v/is_instance_of
```
JIRA Issue: BA-3133
Contributor guide
Assessment
This issue has not been assessed yet.