Optimize relationship visibility and org path handling#470
Optimize relationship visibility and org path handling#470yaojin3616 wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b5f8706ad
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if item.target_agent_id == str(agent_id): | ||
| continue |
There was a problem hiding this comment.
Normalize target IDs before filtering self relationships
The new self-reference guard compares item.target_agent_id to str(agent_id) as raw strings, but save_agent_relationships no longer re-checks after parsing to UUID. If a client sends an equivalent UUID in a different string form (e.g., uppercase or brace-wrapped), this check is bypassed and the API can persist an agent-to-itself relationship, which the previous implementation explicitly prevented.
Useful? React with 👍 / 👎.
| # Path is rebuilt from the internal department tree after sync. | ||
| path = dept.name |
There was a problem hiding this comment.
Keep parent linkage resilient to unordered department sync
This change drops the provider-side parent hint from path and relies on post-sync rebuilding from parent_id, but parent_id is only set when the parent row already exists during upsert. If departments arrive child-before-parent (the WeCom adapter consumes API order directly), children are saved with parent_id=None, and the rebuild then writes flattened top-level paths, which propagates incorrect org paths to members and breaks hierarchical department filtering until a later sync happens to reorder correctly.
Useful? React with 👍 / 👎.
Summary
Validation