Skip to content

Fix/Bitbucket Integration Issues.#27

Merged
Amazing-Stardom merged 16 commits intomasterfrom
fix/github-connector
Apr 25, 2026
Merged

Fix/Bitbucket Integration Issues.#27
Amazing-Stardom merged 16 commits intomasterfrom
fix/github-connector

Conversation

@Amazing-Stardom
Copy link
Copy Markdown
Contributor

@Amazing-Stardom Amazing-Stardom commented Apr 11, 2026

Bitbucket Integrations Issues and Other Small Issues Fixed

Issues in Posting a Comment on a Deleted Line in Bitbucket

This was bug in identifying deleted line comment.

  1. Comments were not posting in deleted lines due to lineIsDeleted function not identifying it.
    The original function was finding the string "-" in diff.
    This was getting missed by identification.
    This was working correctly in other platforms because they allowed commenting on deleted lines.
    Bitbucket had issues with commenting on deleted lines.

As this diff content is formatted with OLD | NEW | CONTENT lines.
I used parsing this data and able to identify deleted line comments correctly.
Fixed it and added a simple test case.

Bitbucket API Issues

  1. Bitbucket PR review was not created because the repo URL is missing. Hence, it couldn't fetch PR details.
image Root cause: Empty string passed to provider function. This function required a repo URL. Fixed it by storing the repo URL and passing the repo URL to the function. image
  1. Bitbucket Comments were not posting due to an empty function. Missed during the last refactor of network unification.
image

This was fixed by adding functions from old commits.

  1. LLM response error directly posted to comment.
    Fixed it by adding more general content.
image image
  1. The reply to the Bitbucket comment was broken.
    fixed it by adding discussion ID
image
  1. Added Gitea wiki documentation in the create connector UI.
image

Unification of Bitbucket Network

  1. As many function calls were missing in the Bitbucket comment posting. Most of these functions missed unification.
  2. Currently unified all the API calls. This is done based on rules defined for adding to docs.

LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
LiveReview Pre-Commit Check: ran (iter:3, coverage:40%)
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
LiveReview Pre-Commit Check: ran (iter:4, coverage:69%)
LiveReview Pre-Commit Check: ran (iter:6, coverage:100%)
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
LiveReview Pre-Commit Check: ran (iter:2, coverage:59%)
@Amazing-Stardom
Copy link
Copy Markdown
Contributor Author

Severity: info

Fix Bitbucket Diff Parsing and Centralize API Operations

Overview

This change fixes a critical bug in Bitbucket diff parsing for AI comments. It centralizes Bitbucket API network operations into a dedicated package. It also implements robust Bitbucket comment posting and improves context propagation.

Technical Highlights

  • internal/ai/langchain/provider.go: Refactor lineIsDeleted to parse 'OLD | NEW | CONTENT' diff format.
  • network/providers/bitbucket/http_client_ops.go: Introduce new package to centralize Bitbucket HTTP client operations.
  • internal/providers/bitbucket/bitbucket.go: Implement PostComment with inline fallback and context.Context propagation.
  • cmd/mrmodel/lib/bitbucket.go: Propagate context.Context to all Bitbucket API calls.
  • internal/api/unified_processor_v2.go: Dynamically fetch Bitbucket user email from metadata for authentication.
  • internal/review/factories.go: Enforce repo_url as a mandatory configuration for Bitbucket provider creation.

Impact

  • Functionality: AI-generated comments now accurately identify deleted lines in Bitbucket diffs. Bitbucket comment posting is robust, supporting inline comments with fallbacks. Bitbucket API calls are more reliable with proper context handling.
  • Risk: Inline comment fallback may result in general comments if line numbers are mismatched. New repo_url validation might break existing misconfigured Bitbucket providers.

Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread cmd/mrmodel/lib/bitbucket.go
Comment thread internal/ai/langchain/json_repair_integration_test.go
Comment thread internal/ai/langchain/provider.go Outdated
Comment thread internal/ai/langchain/provider.go Outdated
Comment thread internal/ai/langchain/provider.go
Comment thread internal/ai/langchain/provider.go Outdated
Comment thread internal/ai/langchain/provider.go Outdated
Comment thread internal/ai/langchain/provider.go Outdated
Comment thread internal/ai/langchain/provider.go Outdated
Comment thread internal/api/bitbucket_profile.go
Comment thread internal/api/bitbucket_profile.go
Comment thread internal/api/bitbucket_profile.go
Comment thread internal/api/bitbucket_profile.go Outdated
Comment thread internal/api/reviews_api.go
Comment thread internal/api/unified_processor_v2.go
Comment thread internal/api/unified_processor_v2.go
Comment thread internal/api/unified_processor_v2.go
Comment thread internal/providers/bitbucket/bitbucket.go Outdated
Comment thread network/providers/bitbucket/http_client_ops.go Outdated
Comment thread network/providers/bitbucket/http_client_ops.go Outdated
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
LiveReview Pre-Commit Check: ran (iter:2, coverage:37%)
@Amazing-Stardom Amazing-Stardom changed the base branch from loc-pricing to master April 25, 2026 04:43
if repoURL == "" {
return nil, fmt.Errorf("failed to create bitbucket provider: repo_url is required but was not provided")
}
log.Printf("[DEBUG] Bitbucket token exists: %v, email: %s, repoURL: %s", len(apiToken) > 0, email, repoURL)
if repoURL == "" {
return nil, fmt.Errorf("failed to create bitbucket provider: repo_url is required but was not provided")
}
log.Printf("[DEBUG] Bitbucket token exists: %v, email: %s, repoURL: %s", len(apiToken) > 0, email, repoURL)
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
@Amazing-Stardom Amazing-Stardom merged commit 2c8779a into master Apr 25, 2026
15 of 16 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.

2 participants