Skip to content

fix: use Feishu global user API for org sync to bypass department hie…#295

Open
bigbearcool wants to merge 1 commit intodataelement:mainfrom
bigbearcool:feishu-global-user-sync
Open

fix: use Feishu global user API for org sync to bypass department hie…#295
bigbearcool wants to merge 1 commit intodataelement:mainfrom
bigbearcool:feishu-global-user-sync

Conversation

@bigbearcool
Copy link
Copy Markdown

…rarchy limits

  • Override sync_org_structure() to use contact/v3/users (global list) API
  • Add _fetch_all_users() method using global user list endpoint
  • Replace per-department fetch_users with global user fetch
  • Works regardless of department hierarchy position, fixes root-dept access issues
  • Fixes: Feishu API returns no-dept-authority error when fetching root department users

Summary

Checklist

  • Tested locally
  • No unrelated changes included

…rarchy limits

- Override sync_org_structure() to use contact/v3/users (global list) API
- Add _fetch_all_users() method using global user list endpoint
- Replace per-department fetch_users with global user fetch
- Works regardless of department hierarchy position, fixes root-dept access issues
- Fixes: Feishu API returns no-dept-authority error when fetching root department users
@wisdomqin
Copy link
Copy Markdown
Contributor

Thanks for the detailed work and for isolating this into its own PR.

After reviewing the change and cross-referencing our git history, we can't merge the Feishu global user API switch at this time. Here's why:

  1. Status regression: This reverts commit f05d0ca which was an intentional fix — employees who haven't completed account activation (is_activated=False) should still appear as active in the org chart. Mapping them to inactive incorrectly hides valid employees.

  2. Reconciliation risk: The _reconcile() step marks any member not refreshed during a sync cycle as deleted. Replacing raise with break on API error means a partial sync silently marks all remaining members as deleted — the org chart could be wiped on a transient API failure.

  3. Non-deterministic department assignment: Using department_ids[0] from the global API is fragile — Feishu doesn't guarantee ordering, so a user's primary department can change between syncs.

Rather than asking you to iterate on the implementation, we'd like to understand the underlying problem you're solving. Could you describe:

  • What specific Feishu app permission or setup constraint is blocking the current per-department sync for you?
  • Is the issue that contact:user.employee_id:readonly permission is unavailable in your Feishu organization?
  • How large is your org (approximate user count) — is the global API approach also about performance?

We'll incorporate a proper solution into a future release. Closing this PR for now, but please share your requirements and we'll pick it up from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants