Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Integration][ADO] Bug Fix: Default mapping errors #989

Merged

Conversation

oiadebayo
Copy link
Member

@oiadebayo oiadebayo commented Sep 5, 2024

Description

What -
This PR addresses a few bugs and improvements in the Azure DevOps (ADO) integration related to the default mappings for service and work-item entities, handling of project data, and logging enhancements.

Why -

  • The original default mapping for services caused errors when repository names contained special characters like parentheses. The error prevented the repositories from being imported into Port.
  • The work-item mapping had an issue where the relation to the project was incorrectly based on System.TeamProject, which referenced the project name instead of the internal project identifier
  • It was necessary to update the mapping so that full project data, not just the project ID, is passed to the work-item entities
  • Additionally, to aid in debugging and monitoring, general logs should be displayed when the integration is querying the work items.

How -

  • The mapping for services was updated to removing additional special characters that could cause the repository name to fail.
  • The work-item mapping was updated to reference the __projectId, extracting the correct internal project identifier, ensuring accurate associations in Port.
  • The integration was improved to pass full project data to work-item entities instead of just the project ID
  • Added general logging to the integration to display information when querying work items, which will help in tracking the integration's activity and diagnosing issues.

Type of change

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

  • Bug fix (non-breaking change which fixes an issue)

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.

API Documentation

Provide links to the API documentation used for this integration.

@oiadebayo oiadebayo requested a review from PeyGis September 5, 2024 08:01
@oiadebayo oiadebayo requested a review from a team as a code owner September 5, 2024 08:01
@oiadebayo oiadebayo removed the request for review from a team September 5, 2024 08:01
@github-actions github-actions bot added the size/M label Sep 5, 2024
Copy link
Contributor

@PeyGis PeyGis left a comment

Choose a reason for hiding this comment

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

left some comments

resources:
- kind: project
selector:
query: 'true'
defaultTeam: "true"
defaultTeam: true
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be 'true'?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 227 to 229
def _add_project_id_to_work_items(
self, work_items: list[dict[str, Any]], project_id: str
) -> None:
self, work_items: list[dict[str, Any]], project_id: str, project: dict[str, Any]
) -> list[dict[str, Any]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

rename the function to __add_project_details_to_work_items(self, work_item, project)

then you can do
__projectId = project["id]
__project = project

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@PeyGis PeyGis left a comment

Choose a reason for hiding this comment

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

LGTM

relations:
project: '.fields."System.TeamProject" | gsub(" "; "")'
project: .__projectId
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be also updated to be without special characters?

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch

@Tankilevitch Tankilevitch merged commit 4caa81d into main Sep 5, 2024
15 checks passed
@Tankilevitch Tankilevitch deleted the PORT-10192-PORT-10191-Bug-ADO-Default-mapping-error branch September 5, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants