Skip to content

Conversation

raunakab
Copy link
Contributor

@raunakab raunakab commented Jun 27, 2025

Description

During initial sync, the ExternalAccess.external_user_emails field of a Document will always be populated with a set of actual user-emails, regardless of whether that channel is public or not.

During permission-sync, the ExternalAccess.external_user_emails will only be populated with the actual emails if that channel is private. Otherwise (if it's public), it'll set that field to the empty set.

This is asymmetric behaviour; we want both initial-indexing + permission-sync to produce identical ExternalAccess instances (given that the underlying document's permissions have not changed).

This PR fixes that issue.

Addresses: https://linear.app/danswer/issue/DAN-2150/fix-asymmetric-bug-in-externalaccess-generation-for-perm-sync-vs.

How Has This Been Tested?

Existing tests are sufficient.

@raunakab raunakab requested a review from a team as a code owner June 27, 2025 20:53
Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 11:37pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Fixed asymmetric permission handling in Teams connector where email addresses were inconsistently populated between regular indexing and slim-document retrieval paths.

  • Consolidated permission logic into new fetch_external_access utility in backend/onyx/connectors/teams/utils.py to ensure consistent behavior across retrieval paths
  • Added public() classmethod to ExternalAccess in backend/onyx/access/models.py for standardized creation of public document instances
  • Removed redundant _is_channel_public helper and moved _PUBLIC_MEMBERSHIP_TYPE constant to module level for better organization
  • Ensured ExternalAccess instances maintain identical states between slim and full document retrieval

3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

@raunakab raunakab requested a review from evan-onyx June 27, 2025 20:55
@raunakab raunakab enabled auto-merge June 27, 2025 21:19
@raunakab raunakab requested a review from Orbital-Web June 27, 2025 21:20
@raunakab raunakab changed the title fix: Fix bug in which emails would be fetched during regular indexing fix: Fix bug in which emails would be fetched during initial indexing Jun 27, 2025
Copy link
Contributor

@Orbital-Web Orbital-Web left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, left a comment

Copy link
Contributor

@evan-onyx evan-onyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 nit

@Weves Weves disabled auto-merge June 28, 2025 05:05
@Weves Weves merged commit 809122f into main Jun 28, 2025
11 of 15 checks passed
@Weves Weves deleted the fix/teams-perm-connector-tests branch June 28, 2025 05:05
AnkitTukatek pushed a commit to TukaTek/onyx that referenced this pull request Sep 23, 2025
…onyx-dot-app#4959)

* Add new convenience method

* Fix bug in which emails would be fetched for initial indexing

* Improve tests for MS Teams connector

* Fix test_gdrive_perm_sync_with_real_data patching

* Protect against incorrect truthiness

---------

Co-authored-by: Weves <chrisweaver101@gmail.com>
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.

4 participants