Skip to content

Fix $mask variable mutation in GetDependencies inner loop#2247

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-getdependencies-bug
Open

Fix $mask variable mutation in GetDependencies inner loop#2247
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-getdependencies-bug

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

❔What, Why & How

GetDependencies mutates the outer foreach($mask in $masks) loop variable inside the inner foreach($dependency in $probingPathsJson) loop when prepending buildMode. This causes the mask to accumulate prefixes across dependency iterations:

Iteration 1: App_xyz has buildMode "ONPREM" → $mask becomes "ONPREMApps"
Iteration 2: App_abc has no buildMode       → $mask becomes "ONPREMONPREMApps"

Introduced a local $currentMask variable initialized from $mask at the top of the inner loop. All inner-loop references now use $currentMask, leaving the outer loop variable untouched.

foreach($mask in $masks) {
    foreach($dependency in $probingPathsJson) {
        $currentMask = $mask                      # local copy
        if($buildMode -ne "Default") {
            $currentMask = "$buildMode$currentMask" # mutate copy, not outer var
        }
    }
}

Related to issue: #2236

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

The outer foreach loop variable $mask was being reassigned inside the
inner foreach loop when prepending the buildMode. This caused incorrect
artifact mask names when iterating over multiple dependencies with
different build modes. Introduced a local $currentMask variable to
preserve the original $mask value across inner loop iterations.

Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/57de4c0d-e2ce-40ca-9c16-0cd1503b3c8f

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug in AL-Go's GetDependencies function Fix $mask variable mutation in GetDependencies inner loop May 11, 2026
Copilot AI requested a review from mazhelez May 11, 2026 21:00
@mazhelez
Copy link
Copy Markdown
Collaborator

@copilot awesome! Please include release notes.

Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/36cbe5be-4091-488a-af40-a744e4c0694a

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilot awesome! Please include release notes.

Added in a4cb1a2.

@mazhelez mazhelez marked this pull request as ready for review May 11, 2026 21:08
@mazhelez mazhelez requested a review from a team as a code owner May 11, 2026 21:08
Copilot AI review requested due to automatic review settings May 11, 2026 21:08
@mazhelez
Copy link
Copy Markdown
Collaborator

@copilot for the release notes, can you please follow the pattern and include the issue number?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilot for the release notes, can you please follow the pattern and include the issue number?

Updated to follow the pattern with Issue 2236 in dffa6a0.

Copilot AI requested a review from mazhelez May 11, 2026 21:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a bug in GetDependencies where the artifact mask string was being mutated across inner-loop iterations, leading to incorrect artifact name masks when multiple dependency probing paths use different buildMode values.

Changes:

  • Introduces a per-iteration $currentMask to prevent mutation of the outer $mask variable.
  • Updates all inner-loop usages to reference $currentMask instead of $mask.
  • Adds a release note entry documenting the issue and fix.

Reviewed changes

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

File Description
RELEASENOTES.md Documents the fixed GetDependencies mask prefix leak (Issue 2236).
Actions/Github-Helper.psm1 Stops mutating the outer $mask by switching inner-loop logic to a local $currentMask.

Comment thread Actions/Github-Helper.psm1
Comment thread Actions/Github-Helper.psm1
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.

[Bug]: bug in AL-Go's GetDependencies function

4 participants