microsoft / DevHomeAzureExtension

Dev Home Azure Extension
MIT License
81 stars 18 forks source link

Some Azure DevOps Server URLs are falsely considered invalid #164

Open Az8th opened 7 months ago

Az8th commented 7 months ago

Dev Home version

0.1201.442.0

Dev Home Azure Extension version

0.700.442.0

Windows build number

22621.3447

Other software

Azure DevOps Server 2022.1 (20231128.1)

Steps to reproduce the bug

  1. Add a pull request widget
  2. Select account
  3. Add the repo URL (https://azdo.example.com/azdo/collection/project/_git/repository)
  4. Click on save

  5. Add a query result widget
  6. Select account
  7. Add the query URL (https://azdo.example.com/azdo/collection/project/_queries/query/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/)
  8. Click on save

Expected result

Plugins should work properly and accept the URL

Actual result

The specified URL is not a repository URL. or The specified URL is not a query URL. errors are raised.

Included System Information

Thanks for adding Azure DevOps Server support !

Unfortunately, it seems that the URL input handling is too sensitive, as if anything is put between the third / and collection, it is considered an unvalid url, despite being otherwise.

As any URL shoud be customizable (outside of the Azure DevOps API), I suggest to match this in the widget implementation.

Have a nice day !

dkbennett commented 6 months ago

@Az8th is the URL you are trying to input an on-prem url, or is it one of the *.visualstudio.com or dev.azure.com? Hosted urls are processed differently from non-hosted.

I'm assuming this an on-prem server, and if so the URL has ambiguity.

If this is the actual URL, meaning it an on-prem server, here's the issue: https://azdo.example.com/azdo/collection/project/_git/repository.

The root issue is that it is assuming the 'azdo' after the hostname is a project name or a collection name, not part of the organization connection URL, and as such we assume that it is an invalid format because there's too many segments ('azdo', 'collection', and 'project'). Since the hostname is not azure.com or visualstudio.com we can probably assume > 3 segments before the '_git' segment means the 'azdo' segment is part of the organization name and connection.

The problem comes in when 'collection' is omitted because it's optional, then we have an ambiguous situation: 'azdo/project/_git' could mean that 'azdo' is the collection name, or it could be part of the organization. I can fix the 3-segment situation you have provided, and assume in such a configuration that '/azdo' is part of the organization URL. I could do that and assume 'collection' is always present since it usually is, but we would then likely have a bug when collection is omitted.  I suspect collection omissions in on-prem are rare, however, and in other parts of the url processing we assume it is there. So I can fix this by assuming collection is alwasy there, in which case an on-prem URL that has > 2 segments we assume everything before the collection/project/_git part is part of the organization/connection name.

Az8th commented 4 months ago

Sorry, I left my reply unposted :/ I confirm that it is an on-prem URL.

Your solution seems good to me, I would add that knowing the URL type would remove the possibility of a misleading when the collection argument is not provided. It is possible to check if a project URL is valid thanks to the API, but I would rather suggest to add an "OnPrem" checkbox to the widget settings

Az8th commented 1 month ago

Hello, is there any update or way we can help about this issue ?