Repository navigation
Improve inter-branch merge configuration errors - #17384
Conversation
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
There was a problem hiding this comment.
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
MergeToBranchitself 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
There was a problem hiding this comment.
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-WebRequestHTTP/network error that is emitted as non-terminating can bypass thiscatch; the script then reports a generic later error instead of the intended fetch failure and HTTP status. Add-ErrorAction Stopto make the download-failure classification reliable.
$response = Invoke-WebRequest -UseBasicParsing -Method GET -MaximumRetryCount 3 -Headers $headers `
$urlToConfigurationFile
There was a problem hiding this comment.
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
ResetToTargetPathsis 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/*"becomess;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 ";"
}
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
|
@mmitche please take a look :) |
There was a problem hiding this comment.
🟡 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
There was a problem hiding this comment.
🟢 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
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 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
|
@mmitche not sure if this PR is still necessary, but let me know either way! |
There was a problem hiding this comment.
🟢 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
There was a problem hiding this comment.
🟢 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
Summary
MergeToBranchValidation
MergeToBranchfail with targeted messagesAzure DevOps work item: https://dev.azure.com/dnceng/internal/_workitems/edit/10214