Skip to content

Conversation

danielkravets
Copy link
Contributor

@danielkravets danielkravets commented Aug 30, 2025

Bitbucket Cloud Connector

This pull request introduces a new connector for Bitbucket Cloud, allowing users to index and search pull requests from their repositories. The connector can be configured to target specific repositories, all repositories within one or more projects, or an entire workspace. It also has options for retaining closed PRs for specified amount of days.

I used Confluence, GitHub, and GitLab connectors as references. It uses the Bitbucket Cloud API and includes error handling and backoff/limiting strategies.

How to Test

You can test this connector using any public Bitbucket Cloud repository. For convenience, Atlassian's public repositories are a great target for testing.

API token and connector creation video.

  1. Credentials: Create a Bitbucket API Token with read permissions for Projects, Repositories, and Pull Requests. (see documentation PR for This connector)
  2. Configuration in Onyx:
    • Workspace: dokv
    • Projects: You can specify a project key, for example, PEAL (Sourcetree for Jira).
    • Alternatively, you can leave the projects field blank and specify repository slugs directly.
  3. Connect and run a full sync.

You can use my own sample public repositories at https://bitbucket.org/dokv/workspace/projects/PEAL.


Summary by cubic

Add a Bitbucket Cloud connector to index pull requests. Includes scoping by workspace/project/repo, optional pruning of closed PRs, slim sync, and a UI to configure credentials.

  • New Features

    • Backend connector (Load/Poll/Slim) using Bitbucket API with retry and rate limiting; maps PRs to documents and validates credentials.
    • Config options: workspace, repositories, projects, prune_closed_prs_after_days.
    • Auth via email + API token (app password).
    • Web updates: Bitbucket icon, connector form, credential template, source metadata, and enums; backend wiring via DocumentSource and factory.
    • Tests for full and slim document flows.
  • Migration

    • Create a Bitbucket API token with read access to Projects, Repositories, and Pull Requests.
    • Add credentials: email and api_token.
    • Configure: set workspace; choose repositories, or projects, or entire workspace; optionally set prune_closed_prs_after_days (-1 disables).
    • Run a full sync.

@danielkravets danielkravets requested a review from a team as a code owner August 30, 2025 20:07
Copy link

vercel bot commented Aug 30, 2025

@danielkravets is attempting to deploy a commit to the Danswer Team on Vercel.

A member of the Team first needs to authorize it.

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 introduces a comprehensive Bitbucket Cloud connector that enables users to index and search pull requests from their Bitbucket repositories. The implementation follows established patterns from existing connectors like GitHub, GitLab, and Confluence, providing a consistent user experience.

Backend Implementation:

  • Connector Architecture: The BitbucketConnector class implements the standard connector interfaces (LoadConnector, PollConnector, SlimConnector) with comprehensive API integration, retry logic, and rate limiting
  • Flexible Targeting: Supports three indexing modes - specific repositories, all repositories within projects, or entire workspace scanning
  • Pruning Logic: Includes configurable retention of closed pull requests with time-based cleanup (default disabled with -1 days)
  • API Integration: Utilizes Bitbucket Cloud API with proper authentication via email/API token, comprehensive field selection, and pagination handling
  • Document Mapping: Transforms Bitbucket PR data into Onyx's Document format with rich metadata preservation including author information, timestamps, and PR details

Frontend Integration:

  • UI Configuration: Tab-based configuration interface allowing users to choose between repository, project, or workspace-level indexing
  • Credential Management: Integrates with existing credential system requiring email and API token for authentication
  • Visual Elements: Includes proper Bitbucket branding with official colors and logo in the BitbucketIcon component
  • Type Safety: Full TypeScript support with proper interface definitions (BitbucketCredentialJson, BitbucketConfig)

System Integration:

  • Source Registration: Properly registers BITBUCKET as a new DocumentSource throughout the system (constants, factory, types)
  • Testing Framework: Includes comprehensive test suite covering basic functionality, polling, and slim document operations
  • Documentation Ready: Structured to integrate with existing documentation patterns

The connector architecture supports both full indexing and incremental updates, making it suitable for organizations of various sizes. The implementation demonstrates solid understanding of Onyx's connector framework and maintains consistency with existing patterns while accommodating Bitbucket-specific requirements.

Confidence score: 4/5

  • This PR introduces a well-structured connector with comprehensive functionality, but contains some implementation concerns that should be addressed
  • Score reflects solid overall architecture following established patterns, but points are deducted for test logic issues and potential edge case handling
  • Pay close attention to the test files and connector validation logic which contain critical issues that could cause failures

14 files reviewed, 4 comments

Edit Code Review Bot Settings | Greptile


def test_bitbucket_poll_source(bitbucket_connector: BitbucketConnector) -> None:
current = time.time()
specific_date = 1755004439 # Tue Aug 12 2025 13:13:59.797 UTC
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Future timestamp will cause test failure. Use a past date or dynamic calculation based on current time

Suggested change
specific_date = 1755004439 # Tue Aug 12 2025 13:13:59.797 UTC
specific_date = int(current - 86400 * 30) # 30 days ago

Copy link
Contributor Author

@danielkravets danielkravets Aug 30, 2025

Choose a reason for hiding this comment

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

For this test, I used my own workspace, and I don't want the test to expire (pull nothing).
The specific date is exactly for the test to do a meaningful job.
But just let me know if this is important.

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.

4 issues found across 14 files

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

@danielkravets danielkravets force-pushed the bitbucket_connector branch 2 times, most recently from 072ac37 to ff511e2 Compare September 1, 2025 15:36
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.

13 issues found across 14 files

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

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

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

Choose a reason for hiding this comment

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

Numeric field will be validated as a string because the schema lacks a number case; add Yup.number() handling in createConnectorValidationSchema to enforce numeric input and avoid coercion issues.

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

<comment>Numeric field will be validated as a string because the schema lacks a number case; add Yup.number() handling in createConnectorValidationSchema to enforce numeric input and avoid coercion issues.</comment>

<file context>
@@ -282,6 +282,80 @@ export const connectorConfigs: Record&lt;
+    ],
+    advanced_values: [
+      {
+        type: &quot;number&quot;,
+        description:
+          &quot;Prune closed PRs after N days (use -1 to disable pruning, 0 to prune immediately)&quot;,
</file context>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if this is relevant, looks that other connectors are dealing with numbers in the same way

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 14 files

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

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.

5 issues found across 14 files

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

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.

5 issues found across 14 files

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

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.

7 issues found across 14 files

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

@danielkravets danielkravets force-pushed the bitbucket_connector branch 4 times, most recently from 059e0a5 to cc0987e Compare September 1, 2025 18:03
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.

Looks good! Pretty much ready for merging, I just have a few nits. looking forward to getting this in ASAP!

@wenxi-onyx wenxi-onyx merged commit a547112 into onyx-dot-app:main Sep 13, 2025
55 of 60 checks passed
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.

3 participants