Improve inter-branch merge configuration errors - #17384
Open
missymessa wants to merge 2 commits into
Open
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 <223556219+Copilot@users.noreply.github.com> Copilot-Session: 040f9d82-5d74-492a-a03d-71f0143afb36
Contributor
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 <223556219+Copilot@users.noreply.github.com> Copilot-Session: 040f9d82-5d74-492a-a03d-71f0143afb36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MergeToBranchValidation
MergeToBranchfail with targeted messagesAzure DevOps work item: https://dev.azure.com/dnceng/internal/_workitems/edit/10214