Skip to content

Conversation

dennis-bilson-port
Copy link
Member

@dennis-bilson-port dennis-bilson-port commented Aug 25, 2025

User description

Description

What – Fixed issue where pull requests in the Bitbucket Server integration were not unique across multiple repositories during data ingestion.

Why – Duplicate PR records caused confusion and inconsistent data mapping when ingesting from different repositories.

How – Added unique identifiers combining repository information with PR IDs to ensure proper distinction during ingestion.

Type of change

Please leave one option from the following and delete the rest:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • New Integration (non-breaking change which adds a new integration)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Non-breaking change (fix of existing functionality that will not change current behavior)
  • Documentation (added/updated documentation)

All tests should be run against the port production environment(using a testing org).

Core testing checklist

  • Integration able to create all default resources from scratch
  • Resync finishes successfully
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Scheduled resync able to abort existing resync and start a new one
  • Tested with at least 2 integrations from scratch
  • Tested with Kafka and Polling event listeners
  • Tested deletion of entities that don't pass the selector

Integration testing checklist

  • Integration able to create all default resources from scratch
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Resync finishes successfully
  • If new resource kind is added or updated in the integration, add example raw data, mapping and expected result to the examples folder in the integration directory.
  • If resource kind is updated, run the integration with the example data and check if the expected result is achieved
  • If new resource kind is added or updated, validate that live-events for that resource are working as expected
  • Docs PR link here

Preflight checklist

  • Handled rate limiting
  • Handled pagination
  • Implemented the code in async
  • Support Multi account

Screenshots

Include screenshots from your environment showing how the resources of the integration will look.
image
image

API Documentation

Provide links to the API documentation used for this integration.


PR Type

Bug fix


Description

  • Fixed duplicate PR identifiers across multiple repositories

  • Added repository slug/project key prefix to PR identifiers

  • Ensured unique identification during data ingestion


Diagram Walkthrough

flowchart LR
  A["PR ID"] --> B["Repository Slug/Project Key"]
  B --> C["Unique Identifier"]
  C --> D["Data Ingestion"]
Loading

File Walkthrough

Relevant files
Bug fix
port-app-config.yml
Updated PR identifier mapping for uniqueness                         

integrations/bitbucket-server/.port/resources/port-app-config.yml

  • Modified pull-request identifier mapping to include repository
    information
  • Changed from simple .id | tostring to composite identifier format
  • Added repository slug or project key prefix to ensure uniqueness
+1/-1     

@dennis-bilson-port dennis-bilson-port self-assigned this Aug 25, 2025
@dennis-bilson-port dennis-bilson-port changed the title [Integration][BitBucket]PR identifiers not unique across repos [Integration][BitBucket] PR identifiers not unique across repos Aug 25, 2025
@dennis-bilson-port dennis-bilson-port marked this pull request as ready for review August 25, 2025 15:23
Copy link
Contributor

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Data Consistency

Changing the identifier format will create new entities instead of updating existing ones; confirm a migration/backfill strategy or alias handling to prevent duplicate entities post-deploy.

identifier: (.toRef.repository.slug // .toRef.repository.project.key) + "-" + (.id|tostring)
title: .title
Null Handling

If both repository slug and project key are absent or empty, the composite identifier may start with a leading dash and still not be globally unique; consider a fallback (e.g., repository.id) and trimming.

identifier: (.toRef.repository.slug // .toRef.repository.project.key) + "-" + (.id|tostring)
title: .title

Copy link
Contributor

qodo-merge-pro bot commented Aug 25, 2025

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Ensure globally unique identifier

Always include both project key and repository identifier to guarantee
uniqueness across repositories within the same project. Add robust fallbacks
(e.g., repo name or id) and default strings to avoid null-concatenation errors.
This prevents collisions when slug is missing and ensures stable identifiers.

integrations/bitbucket-server/.port/resources/port-app-config.yml [43]

-identifier: (.toRef.repository.slug // .toRef.repository.project.key) + "-" + (.id|tostring)
+identifier: (.toRef.repository.project.key // "unknownProject") + "-" + ((.toRef.repository.slug // .toRef.repository.name // .toRef.repository.id) | tostring) + "-" + (.id | tostring)
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that the PR's logic for creating a unique identifier is flawed and could lead to collisions, proposing a much more robust pattern that combines both project and repository keys to ensure uniqueness.

Medium
  • Update

Copy link
Contributor

@oiadebayo oiadebayo left a comment

Choose a reason for hiding this comment

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

Bump integration version and add changelog

@dennis-bilson-port
Copy link
Member Author

Bump integration version and add changelog

@oiadebayo Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants