Skip to content

fix(tests): add the missing byte order mark to Invoke-MtPackGitHubRequest.Tests.ps1 - #2795

Open
earbona23 wants to merge 2 commits into
maester365:mainfrom
earbona23:fix/bom-invoke-mtpackgithubrequest-tests
Open

earbona23 wants to merge 2 commits into
maester365:mainfrom
earbona23:fix/bom-invoke-mtpackgithubrequest-tests

Conversation

@earbona23

@earbona23 earbona23 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

One byte. FileEncoding.Tests.ps1 requires every tracked PowerShell file to be UTF-8 with a byte order mark, and powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1 arrived without one in #2792 (77f3bdc8). It is the only tracked .ps1 file in the repository that is missing it.

The effect is not limited to main: the Linux leg of build-validation fails there, and every pull request that merges main inherits the failure. I found it while working out why four of my own PRs went red on build-validation (ubuntu-latest) and only on that leg — the general tests, this one included, run on Linux only.

Measured, on main at 02a220b2 and with this change:

main, as it is:        FileEncoding.Tests.ps1   4 passed, 1 failed
                       -> "but got 'powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1'"
with this one byte:    FileEncoding.Tests.ps1   5 passed, 0 failed
                       GeneratedFileFormatting.Tests.ps1   3 passed
                       RepositoryLayout.Tests.ps1         14 passed

Both runs went through powershell/tests/pester.ps1, so on the Pester the repository pins.

Two other failures on that leg, which this does not fix

The same CI run reported four failures out of 8,760. One is the encoding test above. The other three are in Test-MtCaEmergencyAccessExists.Tests.ps1, in the No emergency access config defined (auto-detection mode) block.

Those pass on unmodified main when the file is run on its own — 20 of 20 here, through the same runner. So from the outside they look order- or environment-dependent rather than broken, and I would not want this PR to be read as fixing them. I have not isolated them; if they are known, ignore this paragraph, and if they are not, I am happy to go and find out what state is leaking between files, since a test that only fails in the full suite is the kind that gets ignored until it hides something real.

Summary by CodeRabbit

  • Chores
    • Updated text encoding for a test file.

…uest.Tests.ps1

`FileEncoding.Tests.ps1` requires every tracked PowerShell file to be UTF-8 with
a BOM. This file arrived without one in maester365#2792, so the Linux leg of
build-validation fails on main and on every pull request that merges it.

It is the only tracked .ps1 file in the repository without a BOM.
@earbona23
earbona23 requested a review from a team as a code owner November 11, 2026 15:46
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f140e3a and e6121d3.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The test file now begins with a UTF-8 byte-order mark. Test logic and public declarations did not change.

Changes: Test file encoding

Layer / File(s) Summary
Test file encoding
powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1
The file now begins with a UTF-8 byte-order mark. No test logic changed.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Bug fix

Possibly related PRs

  • maester365/maester#2792: Adds tests in the same file. This change adds a UTF-8 byte-order mark to that test file without changing test behavior.

Suggested reviewers: merill

Merge Risk: Minimal · previous review f140e

This change adds a missing byte-order mark to a test file so the repository's file-encoding check passes. It has no runtime impact and is ready to merge.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding the missing byte-order mark to the specified test file.
Description check Passed The description clearly explains the change, its cause, its CI impact, validation results, and the unrelated failures that remain. It does not reproduce every template heading or checklist item, but t…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the change, its cause, its CI impact, validation results, and the unrelated failures that remain. It does not reproduce every template heading or checklist item, but the required technical information is mostly complete.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 02a220b and f140e3a.

Files selected for processing: 1

  • powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@earbona23

Copy link
Copy Markdown
Contributor Author

Following up on the three failures I said I would go and find: they are #2797, and they are not flaky.

In coverage mode pester.ps1 passes every file to one Invoke-Pester call from its own scope, so a test that reads a variable it never assigned finds the runner's. $config = New-PesterConfiguration is therefore visible to the tests as $config, and Test-MtCaEmergencyAccessExists.Tests.ps1 has five cases that pass $config to the check meaning "nothing configured, auto-detect". Measured with a Write-Host on a throwaway copy:

without coverage:  config-is-null=True   type=
with coverage:     config-is-null=False  type=PesterConfiguration

Three fail; two more pass for the wrong reason. Coverage runs only on the Linux leg, which is why only that leg is red.

So the four failures on that leg are: the byte order mark here, and those three there. On unmodified main at 02a220b2 I get 8,756 tests and 4 failures with PESTER_COVERAGE=true, and 3,989 tests with 0 failures in per-file mode — the same four CI reports. The two PRs together take it to zero.

This one stays a single byte and does not depend on #2797.

@earbona23

Copy link
Copy Markdown
Contributor Author

Update for whoever picks the merge order: the same byte is now in three open PRs.

PR How it carries it
#2795 (this one) the byte is the PR — 1 file, +1/-1
#2800 fix(report): preserve tenant names…, 25 files, includes the hunk
#2733 commit 3b8d487c fix(tests): restore UTF-8 BOM in private pack request tests

All three apply the identical change (ef bb bf before BeforeAll {), and main still does not have it — I checked the first three bytes of the file on main and they are 42 65 66.

That means two things. Whichever of the three lands first turns the hunk in the other two into a conflict on that file, and until one lands, FileEncoding.Tests.ps1 keeps failing on main, which is one of the two causes of the red build-validation (ubuntu-latest) leg. The other cause is #2797.

This PR is the cheapest way out of that: one byte, no behaviour, and it removes the hunk's reason to exist in the other two. I have also just brought it up to date with main (it was BEHIND, which blocks the merge button regardless of review), so the only thing left on it is a maintainer's approval.

Not asking anyone to reorder their work — just making sure the duplication is visible before three people resolve the same conflict.

@earbona23

Copy link
Copy Markdown
Contributor Author

Measured what this one-line change is worth, because the number is the argument.

main's baseline on the Linux leg is 4 failures. This branch runs 3, and the one that disappears is exactly the test this PR exists for:

File encoding
  It saves every tracked PowerShell file as UTF-8 with a byte order mark
Branch build-validation (ubuntu-latest) Run
a PR carrying only main's baseline (#2694) 4 / 8791 tests failed 43052027124
this PR 3 / 8743 tests failed 43231567048
#2797 1 / 8756 tests failed 43231581070

4 = 1 + 3. This PR removes the byte order mark failure; #2797 removes the other three. Together they take the leg to zero, and neither overlaps the other.

Why it is worth landing rather than waiting: 28 of the 40 open non-draft PRs currently show that leg red, and for the ones where the job actually ran the failures are this same baseline, not the contributors' changes. Three PRs built today are green only because they have no ubuntu-latest run at all. So the red is telling every contributor in the repo that they broke something, and none of them did.

Linux is the only leg with PESTER_COVERAGE=true, which is why Windows and macOS are green throughout.

Happy to rebase or split further if that makes it easier to take.

@earbona23

earbona23 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Measured evidence that this PR and #2797 are complementary and that together they take build-validation (ubuntu-latest) to zero failures. Read from the CI logs of four runs, no local run involved.

run PR failures which tests
43231626375 #2794 (unrelated, Intune) 4 / 8760 the BOM test, plus Should pass when a group is excluded from all policies (auto-detected), Should pass when a user is excluded from all policies (auto-detected) and Should only check user-targeted policies when both Agent Identity …
43231567048 #2795 3 / 8743 the BOM failure is gone; the three auto-detection ones remain
43231581070 #2797 1 / 8756 the three auto-detection failures are gone; only the BOM one remains
43489737792 #2805 (today, PIM alerts) 4 / 8760 the same four

The subtraction is clean: the baseline is four, #2795 removes exactly the one it is about, #2797 removes exactly the three it is about, and no other failure appears in any of the four runs. The BOM failure names the file in its own message — powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1 — which is the file #2795 adds the mark to.

Two notes for whoever picks this up:

  • ubuntu-latest is the only leg that fails because it is the only one running with PESTER_COVERAGE, so it is the only one that executes the OS-independent tests. macOS and Windows are green on all four runs.
  • The Smoke_Error and Smoke_Failed lines in those logs are the self-test fixtures and are not failures of the suite; pester.ps1 counts four, and four is what the throw at its line 285 reports.

The totals differ per run (8743, 8756, 8760) because each branch adds its own tests; the failure counts are what matter.

Every open PR against main inherits these four, so the cost of leaving them is paid by every contributor's red check, not only ours.

@earbona23

Copy link
Copy Markdown
Contributor Author

Still REVIEW_REQUIRED with no reviewer assigned. Rather than repeat the arithmetic, here is what I measured across the whole repository today, 14 Nov, because it changes what this PR is worth.

Every open PR that actually runs the suite on Ubuntu is red. All of them.

Of the 45 open non-draft PRs:

state of build-validation (ubuntu-latest) count
red 28
green, but dorny/paths-filter skipped Pester entirely 2
green, Pester really ran — all completed 8–10 Nov 7
no such check recorded 8

The two green ones from today, #2808 and #2809, touch only website/contributors/contributors.yml; their Run Pester tests step is skipped, so the green says nothing about the suite. Since 11 Nov there is not one open PR where Pester ran on Ubuntu and passed — the most recent is #2782 at 2026-11-10T16:15:39Z.

The counts, measured from the job logs rather than the check rollup:

So the red is the repository's, not the pull requests'. The consequence is the part I had not said before: a check that is red on every PR has stopped being a signal. A genuine regression arriving tomorrow lands as red-on-an-already-red PR and is indistinguishable from the four that are already there — including on the 20 PRs by other people, where the author has no reason to suspect the failure is not theirs.

This PR removes one of the four and #2797 removes the other three; together they take build-validation (ubuntu-latest) to zero, with the run links already in the thread above. They are independent of each other and neither changes product code — this one adds a byte order mark to a test file.

Happy to rebase, split, or re-measure anything on request.

@earbona23

Copy link
Copy Markdown
Contributor Author

@merill flagging this one because it is not confined to this pull request: main is red on the Linux leg and has been since #2792, and every branch that merges main inherits it.

Measured just now against the open pull requests: 32 of 56 show build-validation (ubuntu-latest) as a failure. windows-latest and macOS-latest are green on the same runs, and the Pester step really did run there — I checked the step conclusions rather than the rollup, so this is not a skipped job reporting success.

Four tests fail, and between two one-file pull requests they are all four accounted for:

Failure Cause Fix
File encoding — one tracked .ps1 without a byte order mark Invoke-MtPackGitHubRequest.Tests.ps1 arrived without one in #2792 this PR, one byte
Three cases in Test-MtCaEmergencyAccessExists.Tests.ps1 In coverage mode every file goes to one Invoke-Pester call, so a test reading $config without assigning it resolves the runner's own PesterConfiguration instead of $null. Coverage is on only for Linux, which is why only that leg fails #2797

The practical cost is that a contributor cannot tell their own breakage from the repository's. @julien-ly reached the same two diagnoses independently on #2794 while checking whether his branch had caused it, which is the time this is taking from people.

Both are small and neither touches a check. Merging them in either order turns the leg green.

This branch has not been deployed

No deployments
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.

1 participant