Skip to content

fix(server): support Azure DevOps pull request responses - #8364

Open
Kieren-Foenander wants to merge 3 commits into
pingdotgg:mainfrom
Kieren-Foenander:feature/fix/azure-devops-pull-requests
Open

fix(server): support Azure DevOps pull request responses#8364
Kieren-Foenander wants to merge 3 commits into
pingdotgg:mainfrom
Kieren-Foenander:feature/fix/azure-devops-pull-requests

Conversation

@Kieren-Foenander

@Kieren-Foenander Kieren-Foenander commented Aug 27, 2026

Copy link
Copy Markdown

What Changed

  • Read Azure DevOps pull request threads through az devops invoke, reusing the Azure CLI extension authentication.
  • Accept nullable Azure DevOps response fields and normalize thread route data.
  • Fall back to fetching the source branch for same-repository Azure DevOps pull requests, which do not publish a pull-request head ref.
  • Add focused coverage for response decoding, CLI invocation, pull request listing, and branch fetching.

Related issue

Fixes #8078

Why

Azure DevOps responses can contain nullable fields, and same-repository pull requests do not expose the synthetic head refs used by other providers. Those differences caused pull request loading, activity reads, or checkout to fail. This keeps the provider-specific behavior at the Azure DevOps boundary while preserving the existing orchestration flow.

Verification

  • vp test run apps/server/src/git/GitManager.test.ts apps/server/src/pullRequest/AzureDevOpsPullRequestCli.test.ts apps/server/src/pullRequest/azureDevOpsPullRequestJson.test.ts apps/server/src/sourceControl/AzureDevOpsCli.test.ts apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.test.ts (162 tests passed)
  • vp run --filter t3 typecheck
  • Targeted lint and formatting checks for all changed files

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

Created with GPT-5.6 Codex in the T3 Code harness.


Note

Medium Risk
Changes PR head materialization and Azure API/thread contracts (threads replaces threadsUrl); incorrect fork or fallback logic could check out the wrong branch or fail PR threads.

Overview
Hardens Azure DevOps pull request handling so listing, activity, and worktree checkout work when the API returns nulls, fork PRs, or no synthetic pull-request head ref.

Azure pull request JSON decoding now accepts nullable fields and derives cross-repo metadata from forkSource (isCrossRepository, project/repo head identity). That metadata flows through the source-control provider instead of being hardcoded. PR conversation threads move from a REST threadsUrl to a structured AzureDevOpsThreadsRoute, and listThreads uses az devops invoke (shared extension auth) instead of az rest. getRepositoryCloneUrls accepts project/repo and passes --project to az repos show.

In GitManager, same-repository PRs with no resolved head repository still try fetchPullRequestBranch, but on failure they fall back to fetching the named remote head branch (Azure same-repo behavior). PRs with unknown head repository identity no longer take that fallback and surface GitPullRequestMaterializationError instead of checking out an ambiguous same-named branch on origin.

Tests cover decoding, CLI args, fork/incomplete fork cases, worktree prep without pull refs, and the ambiguous-head guard.

Reviewed by Cursor Bugbot for commit 782c693. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix Azure DevOps PR support for forks, null fields, and thread fetching

  • Relaxes AzureDevOpsPullRequestSchema in azureDevOpsPullRequests.ts to accept nulls for optional fields and parses forkSource to compute cross-repository metadata; toChangeRequest in AzureDevOpsSourceControlProvider.ts now propagates isCrossRepository and fork head repo identity instead of hardcoding false
  • Replaces threadsUrl: string | null with a structured AzureDevOpsThreadsRoute across azureDevOpsPullRequestJson.ts, AzureDevOpsPullRequestCli.ts, and AzureDevOpsPullRequestProvider.ts; listThreads now calls az devops invoke instead of az rest
  • Updates getRepositoryCloneUrls in AzureDevOpsCli.ts to accept project/repo specifiers and pass --project to az repos show
  • Adds fallback in materializePullRequestHeadBranchBase in GitManager.ts: for same-repo PRs whose provider does not publish a head ref, fetches the remote head branch by name on failure
  • Risk: AzureDevOpsPullRequest.threadsUrl field is removed and replaced by threads; any out-of-tree code reading threadsUrl will break. normalizeAzureDevOpsPullRequestRecord now returns null cross-repo fields instead of false/empty when fork data is incomplete

Macroscope summarized 782c693.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18361229-a705-4b6c-a8f1-bb565656c891

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 27, 2026

@macroscopeapp macroscopeapp Bot 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.

Effect service conventions review: one change-discipline finding — documentation that recorded why the threads route is derived from Azure's response was dropped while threadsUrl was refactored into the threads route. Service definitions, layers, namespace imports, error modelling, and the added tests otherwise follow the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/pullRequest/azureDevOpsPullRequestJson.ts
Comment thread apps/server/src/pullRequest/azureDevOpsPullRequestJson.ts
@Kieren-Foenander
Kieren-Foenander force-pushed the feature/fix/azure-devops-pull-requests branch from 01913b5 to 8b1ecde Compare August 27, 2026 07:34
Comment thread apps/server/src/git/GitManager.ts
@macroscopeapp

macroscopeapp Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This production change spans Azure response parsing, authenticated thread retrieval, fork repository selection, and Git worktree materialization. The checkout and remote-selection behavior is materially altered across several components, so human validation is appropriate.

You can add or adjust custom eligibility rules. Learn more.

@Kieren-Foenander
Kieren-Foenander force-pushed the feature/fix/azure-devops-pull-requests branch from 8b1ecde to 2f9e77c Compare August 27, 2026 07:53
@Kieren-Foenander

Copy link
Copy Markdown
Author

Addressed the approvability concern in 2f9e77c3. Azure DevOps documents forkSource as the discriminator and source repository for fork PRs. The decoder now preserves that metadata, the source-control provider marks those PRs cross-repository, and GitManager uses its existing fork-remote checkout path. A fork with incomplete identity now fails closed rather than falling back to a same-named primary-remote branch. Regression coverage verifies both decoding and provider propagation; 161 focused tests pass.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Aug 27, 2026
Comment thread apps/server/src/sourceControl/azureDevOpsPullRequests.ts
- Read pull request threads through the Azure DevOps CLI
- Handle nullable Azure fields and same-repository PR refs
@Kieren-Foenander
Kieren-Foenander force-pushed the feature/fix/azure-devops-pull-requests branch from 2f9e77c to f40dbd3 Compare August 27, 2026 08:18

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f40dbd3. Configure here.

Comment thread apps/server/src/sourceControl/azureDevOpsPullRequests.ts Outdated
@Kieren-Foenander

Copy link
Copy Markdown
Author

before vs after testing.

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Azure DevOps PR comments show “most recent 0” because thread request lacks DevOps resource authentication

1 participant