fix: Ensure the id is part of the message pydantic model - #10553
fix: Ensure the id is part of the message pydantic model#10553erichare wants to merge 5 commits into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA new optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 inconclusive)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lfx/src/lfx/schema/message.py (1)
380-394: Propagate theidfield from Message to MessageResponse.The
from_messagemethod doesn't copy the newly addedidfield from the sourceMessageto theMessageResponse. Since both models now have this field and the PR's purpose is to enable message tracking/referencing, the identifier should be preserved during conversion.Apply this diff to propagate the
idfield:return cls( + id=message.id, sender=message.sender, sender_name=message.sender_name, text=message.text, session_id=message.session_id, context_id=message.context_id, files=message.files or [], timestamp=message.timestamp, flow_id=flow_id, )
🧹 Nitpick comments (1)
src/lfx/src/lfx/schema/message.py (1)
38-38: Consider adding a field serializer for theidfield.The
flow_idfield (line 48) with similar typing has both a validator (lines 57-62) and serializer (lines 86-90) to ensure UUID values are consistently converted to strings. Consider adding similar handlers for theidfield to maintain consistency in serialization behavior across the codebase.Apply this diff to add consistent UUID handling:
@field_validator("flow_id", mode="before") @classmethod def validate_flow_id(cls, value): if isinstance(value, UUID): value = str(value) return value + @field_validator("id", mode="before") + @classmethod + def validate_id(cls, value): + if isinstance(value, UUID): + value = str(value) + return value + @field_validator("content_blocks", mode="before")And add a corresponding serializer after line 90:
@field_serializer("flow_id") def serialize_flow_id(self, value): if isinstance(value, UUID): return str(value) return value + @field_serializer("id") + def serialize_id(self, value): + if isinstance(value, UUID): + return str(value) + return value + @field_serializer("timestamp")
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lfx/src/lfx/schema/message.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Update Starter Projects
🔇 Additional comments (1)
src/lfx/src/lfx/schema/message.py (1)
38-38: LGTM! The newidfield follows established patterns.The optional
idfield is well-defined with appropriate typing and default value, consistent with similar fields likeflow_id.
This pull request introduces a small change to the
Messageclass insrc/lfx/src/lfx/schema/message.pyby adding an optionalidfield. This allows each message to have a unique identifier, which can be useful for tracking or referencing messages in the system.Summary by CodeRabbit