Skip to content

fix(azuredevops_go): restore on-premises connection compatibility - #9386

Open
keremoge wants to merge 2 commits into
apache:mainfrom
keremoge:fixazureonprem
Open

keremoge wants to merge 2 commits into
apache:mainfrom
keremoge:fixazureonprem

Conversation

@keremoge

@keremoge keremoge commented Nov 12, 2026 •

Copy link
Copy Markdown

⚠️ Pre Checklist

Please complete ALL items in this checklist, and remove before submitting

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

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.

Copilot AI balanced review requested due to automatic review settings November 12, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Restores Azure DevOps Go plugin compatibility with on-premises Azure DevOps Server by fixing connection form hydration/validation, aligning on-prem URL behavior, and negotiating REST API versions automatically.

Changes:

  • Frontend: make username optional for Azure DevOps Go, restore saved on-prem endpoint + Cloud/Server mode, and validate endpoint requirement in Server mode.
  • Backend: implement on-prem REST API version negotiation (7.2→7.1→7.0→6.0), adjust request URL construction/pagination, and make connection tests fail on project fetch errors.
  • Tests/docs: add regression tests for frontend form behavior and backend version negotiation + on-prem request contracts; update plugin README.
File Description
config-ui/​src/​plugins/​register/​azure/​connection-fields/​connection.test.tsx Adds UI regression tests for optional username and endpoint/mode hydration.
config-ui/​src/​plugins/​register/​azure/​connection-fields/​base-url.tsx Adds Cloud/Server toggle with endpoint hydration and on-prem endpoint validation.
config-ui/​src/​plugins/​register/​azure/​config.tsx Wires new BaseURL props and makes username optional for Azure DevOps Go connections.
config-ui/​src/​plugins/​components/​connection-form/​fields/​username.tsx Adds required prop to support optional username behavior.
backend/​plugins/​azuredevops_go/​tasks/​shared_test.go Adds test ensuring cursor pagination does not send offset parameters.
backend/​plugins/​azuredevops_go/​tasks/​shared.go Fixes paginator to avoid $skip when using cursor mode.
backend/​plugins/​azuredevops_go/​tasks/​ci_cd_timeline_records_collector.go Removes pagination query from build timeline requests.
backend/​plugins/​azuredevops_go/​models/​connection_test.go Adds tests for API-version negotiation and Cloud preview preservation.
backend/​plugins/​azuredevops_go/​models/​api_version.go Implements on-prem API-family detection + per-resource preview version mapping.
backend/​plugins/​azuredevops_go/​impl/​impl.go Clears org prefix for on-prem connections during task preparation.
backend/​plugins/​azuredevops_go/​api/​remote_helper_test.go Adds test ensuring on-prem scope discovery ignores Cloud organization.
backend/​plugins/​azuredevops_go/​api/​remote_helper.go Adjusts org handling for on-prem and parent-id composition.
backend/​plugins/​azuredevops_go/​api/​connection_api.go Makes on-prem Test Connection fail when project fetch fails.
backend/​plugins/​azuredevops_go/​api/​azuredevops/​client_onprem_test.go Adds cross-version on-prem request contract tests + upstream error test.
backend/​plugins/​azuredevops_go/​api/​azuredevops/​client.go Escapes path segments, adds continuation-token support, and improves on-prem URL building.
backend/​plugins/​azuredevops_go/​README.md Updates documentation for on-prem behavior, version negotiation, and endpoint compatibility.

Review effort: Lite

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.

2 participants