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

Enriches Azure autolinks on commits: issues and pull requests #3996

Merged
merged 12 commits into from
Feb 3, 2025

Conversation

sergeibbb
Copy link
Member

@sergeibbb sergeibbb commented Jan 30, 2025

Description

#3977

Issues and PRs on a commit

An open issue

Image

A closed issue

Image

An open PR

Image

A closed PR

Image

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@sergeibbb sergeibbb linked an issue Jan 30, 2025 that may be closed by this pull request
@sergeibbb sergeibbb changed the title 3977 azure autolinks Enriches Azure autolinks on commits issues and pull requests Jan 30, 2025
@sergeibbb
Copy link
Member Author

sergeibbb commented Jan 30, 2025

@axosoft-ramint

Enriched autolinks work. I'm switching to Home. Do you think we can merge what's done without the rest of #3977?
Here are my current changes #3996

What I'm not sure about is whether it's OK that keep saved issue-status -> category data in the API class or there is a better place for it. Move it to the integration?

sergeibbb added a commit that referenced this pull request Jan 30, 2025
sergeibbb added a commit that referenced this pull request Jan 30, 2025
@sergeibbb sergeibbb force-pushed the 3977-azure-autolinks branch from a7e6cea to 81408f8 Compare January 30, 2025 10:45
sergeibbb added a commit that referenced this pull request Jan 30, 2025
let linkIntegration = link.provider
? await this.container.integrations.get(link.provider.id as IntegrationId)
: undefined;
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
Copy link
Member Author

@sergeibbb sergeibbb Jan 30, 2025

Choose a reason for hiding this comment

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

@sergeibbb !
Here with this new ID converting function we'll need to make sure that other types of enriched autolinks are not broken. What do we have? Jira, GitHub Cloud and Ent, GitLab Cloud and Ent. Anything else to check?

Copy link
Contributor

Choose a reason for hiding this comment

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

In some cases like in Jira, we pass the entire integration in as a provider reference, so remoteProviderIdToIntegrationId will fail here. I think in the short term here, we can first try treating link.provider.id as an integration id and try to get the integration from that, and put that in a try/catch so if it fails, then we can try the solution here (try treating it as a remote provider id and convert first before getting the integration).

But in the long term, we need to distinguish, on pull requests, issues, and autolinks, the difference between a remote provider reference and an integration reference. They should be treated separately and put into different properties. If we cannot accomplish that here, we should treat it as a follow-up task.

Copy link
Contributor

Choose a reason for hiding this comment

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

My short term idea would be something like:

Suggested change
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
const integrationId: IntegrationId | undefined = link.provider instanceof Integration ? link.provider.id : isRemoteProviderReference(link.provider) ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
let linkIntegration = integrationId != null ? await this.container.integrations.get(integrationId) : undefined;

But in long term, we should make sure we never put an Integration into provider property, reserve that for remote providers, and instead have a separate integration property or something that is an integration reference.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

sergeibbb added a commit that referenced this pull request Jan 30, 2025
sergeibbb added a commit that referenced this pull request Jan 30, 2025
@sergeibbb sergeibbb force-pushed the 3977-azure-autolinks branch from 81408f8 to 55fa0fa Compare January 30, 2025 11:06
@sergeibbb sergeibbb changed the title Enriches Azure autolinks on commits issues and pull requests Enriches Azure autolinks on commits: issues and pull requests Jan 30, 2025
sergeibbb added a commit that referenced this pull request Jan 30, 2025
@sergeibbb sergeibbb force-pushed the 3977-azure-autolinks branch from 55fa0fa to 7e383a0 Compare January 30, 2025 16:57
Copy link
Contributor

@axosoft-ramint axosoft-ramint left a comment

Choose a reason for hiding this comment

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

Will likely break autolinks for several integrations including Jira, but not really your fault here - we just did a very poor job putting both integrations and remote providers into the same provider property just because they both match the very loose providerreference interface.

We should improve on that. I offer a short-term idea and long-term suggestion below, up to you which you think you can get to for this release.

let linkIntegration = link.provider
? await this.container.integrations.get(link.provider.id as IntegrationId)
: undefined;
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

In some cases like in Jira, we pass the entire integration in as a provider reference, so remoteProviderIdToIntegrationId will fail here. I think in the short term here, we can first try treating link.provider.id as an integration id and try to get the integration from that, and put that in a try/catch so if it fails, then we can try the solution here (try treating it as a remote provider id and convert first before getting the integration).

But in the long term, we need to distinguish, on pull requests, issues, and autolinks, the difference between a remote provider reference and an integration reference. They should be treated separately and put into different properties. If we cannot accomplish that here, we should treat it as a follow-up task.

@@ -1029,13 +1029,8 @@ export class IntegrationService implements Disposable {
}
}

export function remoteProviderIdToIntegrationId(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid setting the input typing to unknown here. I know we messed up by treating integrations as remote provider references in several places, but it would be better to work toward addressing that directly rather than loosening the typing here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@axosoft-ramint Allow it to be astring?
If I require it to be RemoteProviderId it will cause type casting in autolinks.ts where we don't really know an actual type.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

let linkIntegration = link.provider
? await this.container.integrations.get(link.provider.id as IntegrationId)
: undefined;
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

My short term idea would be something like:

Suggested change
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
const integrationId: IntegrationId | undefined = link.provider instanceof Integration ? link.provider.id : isRemoteProviderReference(link.provider) ? remoteProviderIdToIntegrationId(link.provider.id) : undefined;
let linkIntegration = integrationId != null ? await this.container.integrations.get(integrationId) : undefined;

But in long term, we should make sure we never put an Integration into provider property, reserve that for remote providers, and instead have a separate integration property or something that is an integration reference.

src/plus/integrations/providers/azure/models.ts Outdated Show resolved Hide resolved
src/plus/integrations/providers/azure/models.ts Outdated Show resolved Hide resolved
sergeibbb added a commit that referenced this pull request Jan 31, 2025
sergeibbb added a commit that referenced this pull request Jan 31, 2025
sergeibbb added a commit that referenced this pull request Jan 31, 2025
@sergeibbb sergeibbb force-pushed the 3977-azure-autolinks branch from 7e383a0 to fabd51c Compare January 31, 2025 14:12
@axosoft-ramint axosoft-ramint self-requested a review February 3, 2025 23:29
@axosoft-ramint axosoft-ramint merged commit 1a8975c into main Feb 3, 2025
3 checks passed
@axosoft-ramint axosoft-ramint deleted the 3977-azure-autolinks branch February 3, 2025 23:46
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.

Azure DevOps Integration Support - Add Home PR/Issue Support
2 participants