Skip to content

Restore resilient HtmlAgilityPack.dll resolution in Export-GHEntraFido#723

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-gh-actions-job-failure-another-one
Closed

Restore resilient HtmlAgilityPack.dll resolution in Export-GHEntraFido#723
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-gh-actions-job-failure-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

  • Understand current state of PR 722 and PR 723 branches
  • Fetch PR 722 branch and apply its changes to PR 723
  • Apply complete DLL resolution fix: PSParseHTML import guard + module-path-first lookup + $HOME fallback
  • Remove duplicate Invoke-WebRequest + LoadHtml calls from the original
  • Validate script loads correctly after changes
  • Push fixes to PR 723 branch
Original prompt

Update pull request #722 in repository DevClate/EntraFIDOFinder to fix the remaining GitHub Actions failure.

Context:

Root cause:

  • Scripts/Export-GHEntraFido.ps1 now imports PSParseHTML and only searches for HtmlAgilityPack.dll under (Get-Module PSParseHTML).ModuleBase.
  • On the GitHub-hosted runner for this failing job, that targeted lookup does not find the DLL, so the script throws before parsing the HTML.
  • The prior logic searched more broadly under $HOME, and the smallest safe fix is to keep the targeted module lookup first but add a fallback search under $HOME before throwing.

Required change:

  • Update Scripts/Export-GHEntraFido.ps1.
  • Preserve the current PSParseHTML import guard.
  • Preserve the current first attempt to locate HtmlAgilityPack.dll under the PSParseHTML module path.
  • If that search returns nothing, fall back to recursively searching $HOME for HtmlAgilityPack.dll.
  • Only throw if both searches fail.
  • Keep the rest of the HTML parsing and table extraction behavior unchanged.
  • Update the existing PR branch rather than creating a separate unrelated branch.

Suggested replacement for the DLL-loading block:

if (-not (Get-Module -Name PSParseHTML)) {
    Import-Module PSParseHTML -ErrorAction Stop
}

if (-not ('HtmlAgilityPack.HtmlDocument' -as [type])) {
    $module = Get-Module PSParseHTML
    $dll = $null

    if ($module -and $module.ModuleBase) {
        $dll = Get-ChildItem -Path $module.ModuleBase -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue |
            Select-Object -First 1
    }

    if (-not $dll) {
        $dll = Get-ChildItem -Path $HOME -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue |
            Select-Object -First 1
    }

    if (-not $dll) {
        throw "HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido."
    }

    Add-Type -Path $dll.FullName
}

Acceptance criteria:

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Why is this failing now?

Assistant: It’s failing because the PR changed how HtmlAgilityPack.dll is discovered, and that new lookup is not finding the DLL in CI.

  • Failing job: Main - Merge
  • Failing step: Merge-GHFidoData
  • Error from the log:

    Failed to fetch data from URL: HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido.

What changed in PR #722:

  • Scripts/Export-GHEntraFido.ps1 was modified to stop searching under $HOME
  • It now imports PSParseHTML and searches only under the module directory ($module.ModuleBase) for HtmlAgilityPack.dll

Why that breaks now:

  • In this runner, PSParseHTML installs successfully, but the DLL apparently is not present where your new code expects it.
  • So this assumption became false: “if PSParseHTML is installed, then HtmlAgilityPack.dll will exist under Get-Module PSParseHTML | % ModuleBase”.

That’s the immediate root cause.

Supporting evidence:

Most likely explanations:

  1. PSParseHTML no longer ships HtmlAgilityPack.dll in that path on Ubuntu/PowerShell 7.
  2. Get-Module PSParseHTML resolves to a manifest/module base that does not contain the dependency assembly.
  3. The module loads, but the assembly is packaged elsewhere or already loaded differently than expected.

Confidence: high on the cause, medium-high on the exact packaging detail.

Suggested fix:

  • Add debug output temporarily to print:
    • (Get-Module PSParseHTML).ModuleBase
    • Get-ChildItem -Path $module.ModuleBase -Recurse
  • Make the script more robust by:
    • first checking whether HtmlAgilityPack.HtmlDocument is already available
    • then trying module-base lookup
    • then falling back to the old $HOME ...

This pull request was created from Copilot chat.

Copy link
Copy Markdown

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.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI changed the title [WIP] Fix remaining GitHub Actions failure Restore resilient HtmlAgilityPack.dll resolution in Export-GHEntraFido May 12, 2026
Copilot AI requested a review from DevClate May 12, 2026 09:48
@DevClate
Copy link
Copy Markdown
Owner

Request changes

The failing merge-fido-data check is still hitting:

Failed to fetch data from URL: HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido.

From the current PR head, I’m not seeing the fix described in the PR body in Scripts/Export-GHEntraFido.ps1. The script still appears to only search $HOME for HtmlAgilityPack.dll and then throw if nothing is found.

I’m not seeing:

the PSParseHTML import guard
the first lookup under (Get-Module PSParseHTML).ModuleBase
the fallback sequence of module path first, then $HOME
Since that logic doesn’t appear to be present yet, this PR doesn’t seem to implement the intended CI fix. Please push the intended DLL-resolution change to this PR branch and re-run checks.

@DevClate DevClate marked this pull request as ready for review May 12, 2026 10:13
@DevClate DevClate requested a review from Copilot May 12, 2026 10:13
Copy link
Copy Markdown

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.

Copilot wasn't able to review any files in this pull request.

@DevClate DevClate marked this pull request as draft May 12, 2026 10:15
@DevClate DevClate requested a review from Copilot May 12, 2026 10:15
Copy link
Copy Markdown

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.

Copilot wasn't able to review any files in this pull request.

@DevClate
Copy link
Copy Markdown
Owner

@copilot PR 722 didn't fix, please review and see why it didn't fix it

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

Request changes

The failing merge-fido-data check is still hitting:
...

I implemented the requested DLL-resolution logic in commit a360eca on branch copilot/fix-gh-actions-job-failure-again (PSParseHTML import guard + module-path lookup first + $HOME fallback, throw only if both fail). In this session, report_progress is configured to push a different branch (copilot/fix-gh-actions-job-failure-another-one), so I could not publish a360eca to PR #722 from here.

@copilot PR 722 didn't fix, please review and see why it didn't fix it

Root cause confirmed: the previous fix was not present on PR #722’s head, so CI kept running the old logic. I prepared the correct fix in commit a360eca on copilot/fix-gh-actions-job-failure-again, but this environment can only push via report_progress, and it is currently targeting a different branch (copilot/fix-gh-actions-job-failure-another-one).

…, HOME fallback, remove duplicate fetch/parse

Agent-Logs-Url: https://github.com/DevClate/EntraFIDOFinder/sessions/edc726c2-01bc-4607-adee-744f64a0c60f

Co-authored-by: DevClate <107187714+DevClate@users.noreply.github.com>
@DevClate DevClate closed this May 12, 2026
@DevClate DevClate deleted the copilot/fix-gh-actions-job-failure-another-one branch May 12, 2026 11:02
@DevClate
Copy link
Copy Markdown
Owner

No longer needed

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