Skip to content

feat: zendesk rate limiting#5452

Merged
evan-onyx merged 2 commits intomainfrom
feat/zendesk-rate-limit-config
Sep 18, 2025
Merged

feat: zendesk rate limiting#5452
evan-onyx merged 2 commits intomainfrom
feat/zendesk-rate-limit-config

Conversation

@evan-onyx
Copy link
Contributor

@evan-onyx evan-onyx commented Sep 18, 2025

Description

Addresses https://linear.app/danswer/issue/DAN-1618/address-rate-limiting-for-zendesk
Allow users to specify a requests per minute limit per zendesk connector.

How Has This Been Tested?

tested in UI + unit test

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Summary by cubic

Adds per-connector Zendesk API rate limiting so users can cap requests per minute and avoid hitting Zendesk limits. Includes a UI control and backend enforcement with retry/backoff.

  • New Features
    • Added calls_per_minute to Zendesk connector and client; requests are wrapped with a 60s rate limiter.
    • Handles 429s with Retry-After and exponential backoff.
    • UI: new “API Calls per Minute” advanced numeric setting; config types updated.
    • Added unit test to verify per-minute limiting behavior.

@evan-onyx evan-onyx requested a review from a team as a code owner September 18, 2025 21:29
@vercel
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
internal-search Ready Ready Preview Comment Sep 18, 2025 10:23pm

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.

Greptile Summary

This PR implements configurable rate limiting for Zendesk connectors, allowing users to specify a custom calls_per_minute limit per connector instance. The implementation consists of three main components:

Frontend Configuration: A new number input field is added to the Zendesk connector's advanced settings in web/src/lib/connectors/connectors.tsx. This allows users to specify an API calls per minute limit with helpful documentation referencing Zendesk's official rate limit documentation. The field is optional, maintaining backward compatibility.

Backend Implementation: The ZendeskClient class in backend/onyx/connectors/zendesk/connector.py is restructured to accept a calls_per_minute parameter. The change introduces a new request_with_rate_limit function that dynamically applies rate limiting using the existing rate_limit_builder decorator. This creates a dual-layer approach where proactive client-side rate limiting works alongside the existing reactive 429 response handling.

Testing: A comprehensive unit test in backend/tests/unit/onyx/connectors/zendesk/test_zendesk_rate_limit.py validates the rate limiting functionality using fake time modules to avoid actual delays while testing the timing logic.

The implementation follows established patterns in the codebase, reusing the existing rate limiting infrastructure rather than creating Zendesk-specific logic. It maintains backward compatibility by making the rate limit parameter optional and preserves the existing 429 status code handling as a fallback mechanism.

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it adds optional configuration without breaking existing functionality
  • Score reflects well-structured implementation following established patterns, comprehensive testing, and proper backward compatibility
  • Pay close attention to the backend connector implementation to ensure rate limiting logic integrates correctly with existing retry mechanisms

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@evan-onyx evan-onyx changed the title zendesk rate limiting feat: zendesk rate limiting Sep 18, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 3 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="web/src/lib/connectors/connectors.tsx">

<violation number="1" location="web/src/lib/connectors/connectors.tsx:1076">
Number field will be validated as string; add number-type handling in createConnectorValidationSchema to enforce numeric input (e.g., Yup.number()).</violation>
</file>

<file name="backend/tests/unit/onyx/connectors/zendesk/test_zendesk_rate_limit.py">

<violation number="1" location="backend/tests/unit/onyx/connectors/zendesk/test_zendesk_rate_limit.py:65">
Replacing the whole requests module with a SimpleNamespace is brittle; patch only requests.get on the module instead.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

advanced_values: [],
advanced_values: [
{
type: "number",
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Sep 18, 2025

Choose a reason for hiding this comment

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

Number field will be validated as string; add number-type handling in createConnectorValidationSchema to enforce numeric input (e.g., Yup.number()).

Prompt for AI agents
Address the following comment on web/src/lib/connectors/connectors.tsx at line 1076:

<comment>Number field will be validated as string; add number-type handling in createConnectorValidationSchema to enforce numeric input (e.g., Yup.number()).</comment>

<file context>
@@ -1071,7 +1071,16 @@ For example, specifying .*-support.* as a &quot;channel&quot; will cause the connector to
-    advanced_values: [],
+    advanced_values: [
+      {
+        type: &quot;number&quot;,
+        label: &quot;API Calls per Minute&quot;,
+        name: &quot;calls_per_minute&quot;,
</file context>
Fix with Cubic

# minimal Zendesk list response (articles path)
return _FakeResponse({"articles": [], "meta": {"has_more": False}})

monkeypatch.setattr(
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Sep 18, 2025

Choose a reason for hiding this comment

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

Replacing the whole requests module with a SimpleNamespace is brittle; patch only requests.get on the module instead.

Prompt for AI agents
Address the following comment on backend/tests/unit/onyx/connectors/zendesk/test_zendesk_rate_limit.py at line 65:

<comment>Replacing the whole requests module with a SimpleNamespace is brittle; patch only requests.get on the module instead.</comment>

<file context>
@@ -0,0 +1,83 @@
+        # minimal Zendesk list response (articles path)
+        return _FakeResponse({&quot;articles&quot;: [], &quot;meta&quot;: {&quot;has_more&quot;: False}})
+
+    monkeypatch.setattr(
+        zendesk_mod, &quot;requests&quot;, types.SimpleNamespace(get=_fake_get), raising=True
+    )
</file context>
Fix with Cubic

@evan-onyx evan-onyx enabled auto-merge September 18, 2025 23:34
@evan-onyx evan-onyx disabled auto-merge September 18, 2025 23:34
@evan-onyx evan-onyx merged commit e82e314 into main Sep 18, 2025
52 of 54 checks passed
@evan-onyx evan-onyx deleted the feat/zendesk-rate-limit-config branch September 18, 2025 23:35
razvanMiu pushed a commit to eea/danswer that referenced this pull request Oct 16, 2025
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