Skip to content

Normalize Azure DevOps PR status failures into GitHostingException - #107

Merged
matt-edmondson merged 2 commits into
mainfrom
copilot/fix-azuredevops-provider-exception
Sep 13, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
copilot/fix-azuredevops-provider-exception

Conversation

Copilot AI commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Azure DevOps pull request status is parsed from an open-ended wire string; unknown values were escaping as NotSupportedException, breaking the provider contract that hosting failures surface via GitHostingException. This change routes unrecognized status values through GitHostingRequestException with provider/HTTP/body context.

  • Behavioral fix

    • AzureDevOpsProvider now maps unknown PR status values to GitHostingRequestException instead of throwing NotSupportedException.
    • Exception includes Name, HttpStatusCode, and raw response body to preserve diagnostics for malformed/preview/future status values.
  • Mapping path update

    • PR mapping now passes response context (statusCode, responseBody) into status conversion so failures are translated in the hosting-exception hierarchy at the point of conversion.
  • Focused coverage

    • Added a targeted test asserting an unrecognized status (e.g. "notSet") from pull request listing throws GitHostingRequestException and carries the response context.
private GitPullRequestState ToGitPullRequestState(string? status, HttpStatusCode statusCode, string responseBody) => status switch
{
	"active" => GitPullRequestState.Open,
	"completed" => GitPullRequestState.Merged,
	"abandoned" => GitPullRequestState.Closed,
	_ => throw new GitHostingRequestException(
		$"Azure DevOps reported an unrecognised pull request status '{status}'.",
		Name,
		statusCode,
		responseBody),
};

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AzureDevOpsProvider to throw GitHostingException Normalize Azure DevOps PR status failures into GitHostingException Sep 13, 2026
@matt-edmondson
matt-edmondson marked this pull request as ready for review September 13, 2026 12:17
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 34d4125 into main Sep 13, 2026
13 of 14 checks passed
@matt-edmondson
matt-edmondson deleted the copilot/fix-azuredevops-provider-exception branch September 13, 2026 12:39
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.

AzureDevOpsProvider throws NotSupportedException instead of GitHostingException for an unrecognized pull request status

2 participants