Skip to content

Improve inter-branch merge configuration errors - #17384

Merged
missymessa merged 14 commits into
dotnet:mainfrom
missymessa:fix-inter-branch-config-errors
Sep 8, 2026
Merged

missymessa merged 14 commits into
dotnet:mainfrom
missymessa:fix-inter-branch-config-errors

Conversation

@missymessa

Copy link
Copy Markdown
Member

Summary

  • distinguish configuration download failures from JSON parsing failures
  • fail the workflow for malformed JSON, invalid schema, and missing MergeToBranch
  • preserve the successful no-op behavior when a valid configuration has no entry for the current branch
  • clarify the no-configuration workflow message

Validation

  • valid MSBuild configuration emits the expected outputs
  • a valid configuration without a branch mapping exits successfully without outputs
  • the historical malformed MSBuild configuration fails with the JSON parser's line and position
  • a missing configuration file fails with its HTTP status
  • invalid schema and missing MergeToBranch fail with targeted messages

Azure DevOps work item: https://dev.azure.com/dnceng/internal/_workitems/edit/10214

Separate download, JSON parsing, and schema validation failures so malformed merge-flow configuration fails with an actionable error while an unconfigured branch remains a successful no-op.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 040f9d82-5d74-492a-a03d-71f0143afb36
Copilot AI lite review requested due to automatic review settings August 21, 2026 20:28

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.

Pull request overview

Improves inter-branch merge configuration error handling and clarifies no-op workflow messaging.

Changes:

  • Separates download, JSON parsing, and schema validation failures.
  • Validates configuration structure and required MergeToBranch.
  • Clarifies the no-configuration workflow message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Summary
.github/workflows/scripts/read-configuration.ps1 Adds configuration parsing and validation. A moderate issue remains: ContainsKey is called before the root-type guard, causing non-object JSON roots to produce method-invocation errors instead of targeted schema errors (lines 74 and 99).
.github/workflows/inter-branch-merge-base.yml Updates the no-configuration workflow message.
Suppressed comments (1)

.github/workflows/scripts/read-configuration.ps1:100

  • This presence check casts the value to a string, so schema-invalid JSON values such as a number, boolean, array, or object can pass as non-empty and be written to the workflow output. The merge step then treats that representation as a branch and can fail later or target the wrong branch. Require MergeToBranch itself to be a string before accepting it.
    if ($configuration.ContainsKey('MergeToBranch') -and
        ![string]::IsNullOrWhiteSpace([string]$configuration['MergeToBranch'])) {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Ensure non-object JSON roots receive the targeted schema error and reject non-string MergeToBranch values before producing workflow outputs.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 040f9d82-5d74-492a-a03d-71f0143afb36
Copilot AI review requested due to automatic review settings August 21, 2026 20:37

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 24, 2026 22:20

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.github/workflows/scripts/read-configuration.ps1:57

  • The request is still using the default error action, so an Invoke-WebRequest HTTP/network error that is emitted as non-terminating can bypass this catch; the script then reports a generic later error instead of the intended fetch failure and HTTP status. Add -ErrorAction Stop to make the download-failure classification reliable.
        $response = Invoke-WebRequest -UseBasicParsing -Method GET -MaximumRetryCount 3 -Headers $headers `
                $urlToConfigurationFile

Copilot AI review requested due to automatic review settings August 27, 2026 00:20

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

.github/workflows/scripts/read-configuration.ps1:116

  • ResetToTargetPaths is joined with -join ";" unconditionally. If the configuration provides a single string instead of an array, PowerShell will join the string’s characters (e.g., "src/*" becomes s;r;c;...), producing incorrect reset patterns. Validate the type and either pass through a string as-is or join an array/enumerable of strings.
    $ResetToTargetPaths = "";
    if ($configuration.ContainsKey('ResetToTargetPaths')) {
        # Convert array to semicolon-separated string for output
        $ResetToTargetPaths = $configuration['ResetToTargetPaths'] -join ";"
    }

Copilot AI review requested due to automatic review settings August 28, 2026 14:48

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Make web request failures terminating so they receive the targeted fetch error. Validate ExtraSwitches and ResetToTargetPaths before emitting workflow outputs, while supporting both string and string-array reset paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a6ad3a92-2023-4c67-8948-f6d34de1a67c
Copilot AI review requested due to automatic review settings August 28, 2026 14:50

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 31, 2026 15:59
@missymessa

Copy link
Copy Markdown
Member Author

@mmitche please take a look :)

Copilot AI review requested due to automatic review settings September 1, 2026 13:58

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.

🟢 Approval recommended

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 2, 2026 15:05

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.

🟡 Changes recommended

The new fetch error handler can emit a PropertyNotFoundException by reading Exception.Response for exception types that don’t expose it, which can obscure the intended targeted error message.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 3, 2026 17:05

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.

🟢 Approval recommended

The changes align with the stated validation goals, improve error specificity, and preserve the intended no-op behavior for unmapped branches without introducing apparent workflow-breaking behavior.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 3, 2026 17:07

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.

🟢 Approval recommended

The changes cleanly implement the stated failure-mode distinctions and schema validations while preserving the intended no-op behavior when no branch mapping exists.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 3, 2026 19:30
@missymessa

Copy link
Copy Markdown
Member Author

@mmitche not sure if this PR is still necessary, but let me know either way!

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.

🟢 Approval recommended

The changes are cohesive, match the stated validation/behavior goals, and preserve the intended “no mapping = successful no-op” path while making malformed/missing configurations fail with targeted errors.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 8, 2026 16:16

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.

🟢 Approval recommended

Changes align with the stated goals, improve error specificity and schema validation, and preserve the intended no-op behavior when no branch mapping exists.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@missymessa
missymessa merged commit 7de4a77 into dotnet:main Sep 8, 2026
2 of 6 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 9, 2026
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.

3 participants