keremoge opened a new pull request, #9386:
URL: https://github.com/apache/devlake/pull/9386

   <!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements. See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License. You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
   ### ⚠️ Pre Checklist
   
   > Please complete _ALL_ items in this checklist, and remove before submitting
   
   - [x] I have read through the [Contributing 
Documentation](https://devlake.apache.org/community/).
   - [x] I have added relevant tests.
   - [x] I have added relevant documentation.
   - [x] I will add labels to the PR, such as `pr-type/bug-fix`, 
`pr-type/feature-development`, etc.
   
   <!--
   Thanks for submitting a pull request!
   
   We appreciate you spending the time to work on these changes.
   Please fill out as many sections below as possible.
   -->
   
   ### Summary
   
   Fix Azure DevOps Go connection configuration, connection testing, and REST 
API compatibility for on-premises Azure DevOps Server installations.
   
   #### Why this PR is needed
   
   Several related issues made on-premises connections unreliable:
   
   1. **Username was not actually optional.** The form displayed “Username 
(Optional for On-Premises)” but still required a username, blocking PAT-based 
connections that do not need one.
   2. **Editing lost the saved deployment mode and URL.** An existing 
on-premises connection could reopen with Azure DevOps Cloud selected and an 
empty server URL because the custom field did not hydrate the saved connection 
values.
   3. **Hardcoded API versions broke older servers.** Requests used fixed API 
versions without accounting for the server’s supported API family or 
resource-specific preview revisions.
   4. **Connection tests could report false success.** Errors while fetching 
projects from an on-premises server were logged but ignored. A connection could 
therefore pass “Test Connection” and fail during discovery or collection.
   
   This PR addresses these issues together so that the connection form, 
connection test, scope discovery, and collection requests use a consistent 
on-premises configuration.
   
   #### Connection form fixes
   
   - Make username optional for Azure DevOps Go connections.
   - Preserve the existing required-by-default behavior for other connectors 
using the shared username field.
   - Restore the saved server URL and Cloud/Server selection, including when 
connection data arrives after the form mounts.
   - Require a server URL in on-premises mode and clear it when switching to 
Cloud.
   
   #### Automatic API-version negotiation
   
   - Use the existing API-client preparation hook to probe API families in 
descending order: **7.2 → 7.1 → 7.0 → 6.0**.
   - Probe with authenticated Projects API requests and accept only a 
successful response containing the expected JSON array.
   - Fall back only for HTTP 400 responses with either:
     - `VssVersionNotSupportedException`
     - `VssVersionOutOfRangeException`
   - Surface authentication, permission, connectivity, and unexpected-response 
errors instead of treating them as version incompatibility.
   - Apply the selected API family to subsequent requests, including 
resource-specific preview revisions.
   - Reuse the selection within each client and detect it again for new 
clients, allowing server upgrades or endpoint changes without a manual version 
setting.
   
   No version-selection field, connection-schema change, or database migration 
is introduced.
   
   #### Request compatibility and collection fixes
   
   - Use collection-relative on-premises URLs without appending a Cloud 
organization prefix.
   - Normalize previously saved task options and scope parent IDs for 
on-premises connections.
   - Escape organization, project, and provider path segments.
   - Skip Cloud Graph account collection for on-premises connections.
   - Use the documented API 6.0 preview revisions:
     - Service endpoints: `6.0-preview.4`
     - Source-provider repositories: `6.0-preview.1`
   - Apply the appropriate resource-specific preview revisions for API 7.2.
   - Remove unsupported PR date-search parameters on API 6.0 and 7.0.
   - Follow source-provider continuation tokens from the response body, 
retaining header fallback and resetting response state between pages.
   - Avoid offset pagination parameters for cursor-paginated requests and 
remove pagination from build timeline requests.
   - Reject upstream errors during external repository discovery instead of 
returning an apparently successful empty result.
   - Propagate project-fetch failures from “Test Connection”.
   
   #### Scope and compatibility
   
   - Automatic API-version negotiation applies only to on-premises connections.
   - Cloud requests retain their existing API-version defaults and explicitly 
requested preview versions.
   - The Python Azure DevOps Cloud plugin is not modified.
   - Plugin documentation now explains connection behavior, API compatibility, 
and pagination requirements.
   
   ### Does this close any open issues?
   
   No linked issue.
   
   ### Screenshots
   
   No screenshots attached. Connection-form regression tests cover optional 
username, saved endpoint/deployment-mode restoration, and Cloud/Server 
switching.
   
   ### Other Information
   
   #### Automated validation
   
   Backend commands were executed from the backend directory using Dockerized 
Go tooling:
   
   - `go test -race ./plugins/azuredevops_go/models 
./plugins/azuredevops_go/api/... ./plugins/azuredevops_go/tasks` — **passed**
   - `go vet ./plugins/azuredevops_go/models ./plugins/azuredevops_go/api/... 
./plugins/azuredevops_go/tasks` — **passed**
   - `go build ./plugins/azuredevops_go/...` — **passed**
   - `golangci-lint run ./plugins/azuredevops_go/...` — **passed, 0 issues**
   
   Frontend commands were executed from the config-ui directory:
   
   - `node .yarn\releases\yarn-4.17.0.cjs test 
src/plugins/register/azure/connection-fields/connection.test.tsx` — **passed, 4 
tests**
   - `node .yarn\releases\yarn-4.17.0.cjs exec tsc --noEmit` — **passed**
   - `node .yarn\releases\yarn-4.17.0.cjs exec eslint 
src/plugins/components/connection-form/fields/username.tsx 
src/plugins/register/azure/config.tsx 
src/plugins/register/azure/connection-fields/base-url.tsx 
src/plugins/register/azure/connection-fields/connection.test.tsx` — **passed**
   
   Repository checks:
   
   - `git diff --check` — **passed**
   - `git diff --cached --check` — **passed**
   
   Regression coverage includes request contracts for nine operations across 
all four API families, authenticated fallback, failure handling, on-premises 
URL construction, pagination, and Cloud preview-version preservation.
   
   #### Manual verification
   
   - Built updated backend and UI Docker images.
   - Verified startup against a separate, fresh MySQL database.
   - Verified backend readiness/health, UI delivery, and UI-to-backend proxying.
   - Verified negotiation to API 6.0 against an accessible on-premises server.
   - Confirmed successful live responses for projects, Git repositories, 
builds, and service endpoints using the compatible versions.
   - The reporter tested the updated Docker deployment and confirmed it works.
   
   #### Limitations and operational notes
   
   - API 6.0 and 7.0 do not support the PR date-search filters used by newer 
versions. These filters are omitted, so collection scans all PR pages and may 
take longer.
   - All four API families have documentation-based and mock HTTP coverage; 
live verification was limited to the available on-premises environment using 
API 6.0.
   - External source-provider repository listing was not fully validated 
against a live provider.
   - “Test Connection” validates API negotiation and project access; it does 
not guarantee permissions for every collection resource.
   - The full repository/E2E suites, SonarQube, and dependency vulnerability 
scans were not run.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to