feat(zendesk): article and ticket access for permission sync
Description
Second PR for Zendesk permission sync, on top of #18699. It adds who may read each article and ticket, sets that access when indexing with permissions and in the perm-sync slim walk, and adds the doc-sync capability checks. The sync is not registered yet; the next PR adds group sync and the registration.
Articles (ee/onyx/external_permissions/zendesk/access.py)
- No user segment: all signed-in users (
<subdomain>:all_users). Public only when Zendesk serves the article to a request without credentials at its localized path (/help_center/{locale}/articles/{id}), checked once per run (is_article_public; a redirect or a non-article answer is not public). - With segments:
<subdomain>:segment:<id>for each, plus<subdomain>:guide_managers.
Tickets
- Admins and agents whose role reads all tickets (private groups too, checked live).
- The ticket's group (
group:<id>), agents whose role adds every public group (public_groups), and agents restricted to the ticket's organization (org_agents:<id>). - The assignee, followers, CCs and requester, by email (from the export's
include=userssideload, so no extra lookups). - End users (requester, CCs, members of an organization that shares tickets) only with the new
grant_end_usersconnector option, and only for tickets without an internal note. The option is off by default: finding internal notes reads every such ticket's comments on each sync, since the ticket events export leaves out some private comments. The form warns that it slows syncing a lot. A user with no known role counts as an end user, and a ticket whose comments return 404 counts as having an internal note.
Connector
CheckpointedConnectorWithPermSync: indexing with permissions reuses the comments it already reads.retrieve_all_slim_docs(pruning) reads no access;retrieve_all_slim_docs_perm_syncsets it.- Both slim walks now skip what indexing skips (drafts, articles without a body or with a skip label, deleted tickets), so pruning removes them. A stop signal raises instead of ending the listing early.
- Fix: tickets read the submitter from
submitter, but the field issubmitter_id, so tickets never had an owner.
Checks (DOC_PERMISSION_SYNC): zendesk_perm_sync_admin (the token's user is an admin), zendesk_article_access, zendesk_ticket_access (users' emails and comments are readable).
How Has This Been Tested?
- Unit: access rules, comment reads only when end users would be granted, the default (no comment reads), skipped items, missing comments, unknown roles, the anonymous probe. The unknown-role and skip tests fail without their fixes.
- Live, against
onyx_ps_fixtures on the CI Zendesk account: indexing and the perm-sync slim walk give the same access for every document, and it matches what each fixture user can open in Zendesk (requester, CC, org peer, follower, private-group member, assignee, restricted segments). tests/daily/connectors/zendesk, the source-operation coverage and import fence tests, and the web connector tests pass.
Docs
- Customer-facing change: I updated
documentation/for the page's reader and task, at the level of detail of the whole page. - No docs change needed: the existing docs stay correct (internal, tests, CI, multi-tenant cloud only, or the UI explains it).
Permission sync is not registered until the next PR, which updates the Zendesk docs page.
Additional Options
- [Optional] Please cherry-pick this PR to the latest release version.
🤖 Generated with Claude Code
Summary by cubic
Adds who may read each Zendesk article and ticket, sets that access when indexing with permission sync and in the permission-sync slim walk, and adds the permission-sync capability checks. Fixes tickets never having an owner because the submitter was read from submitter instead of submitter_id.
- Articles go to their user segments, plus Guide managers; articles without segments go to all signed-in users unless Zendesk serves them without sign-in, probed once per run without credentials while keeping the environment's proxy and CA settings.
- Tickets go to admins, agents by their role's ticket access, the ticket's group, organization-scoped agents, and the requester, assignee, followers, and CCs by email; tickets without a group also go to public-group agents.
- End users (requesters, CCs, and members of organizations that share tickets) get tickets free of internal notes only when the new
grant_end_usersconnector option (off by default) is on, since finding internal notes reads every such ticket's comments and slows syncing a lot; a ticket whose comments are gone counts as having an internal note. - Both slim walks skip what indexing skips, so pruning removes them; a stop signal raises on every item and before the last batch, with progress reported per ticket, instead of ending the listing early.
- The ticket access check probes a live ticket's comments and only warns when the sampled users have no email.
- The sync is not registered yet; the next PR adds group sync and registration.
[!NOTE]
Add Zendesk article and ticket external access for permission sync
- Adds EE permission-sync for Zendesk: article access derives from Help Center visibility and user segments, ticket access from admin/all-ticket groups, ticket groups, organizations, and named users (see access.py)
- Connector separates permission-sync from normal indexing paths; ticket pages request users/groups/organizations sideloads only for permission sync (connector.py)
- New capability checks require an admin user and probe article/ticket reads (capability_checks.py)
- New opt-in
grant_end_users config (default false) grants end-user ticket access but requires reading ticket comments; shown in the ticket connector UI with localized labels in 10 languages
- Behavioral Changes: tickets with an internal note (or a 404 comment read, or a missing/false public comment flag) exclude end-user and organization access; submitter lookup now uses
submitter_id; a stop signal during slim listing now raises RuntimeError instead of returning partial results; end users are not granted access by default
Macroscope summarized 6ab7946.
Summary by CodeRabbit
- New Features
- Zendesk ticket connectors can grant eligible end users, including requesters and CCs, access to tickets without internal notes. This option is available for ticket sources and is off by default; enabling it may increase sync time.
- Permission syncing reflects Zendesk article visibility, ticket groups, organizations, and user roles. Public article access follows Help Center visibility and article segmentation.
- Bug Fixes
- Ticket listings exclude deleted tickets, and article listings omit drafts, skipped articles, and articles without a body.
- Stop requests no longer return partial listings.