Skip to content

Fix HtmlAgilityPack.dll resolution: scope lookup to PSParseHTML module directory#722

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

Fix HtmlAgilityPack.dll resolution: scope lookup to PSParseHTML module directory#722
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-gh-actions-job-failure-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Export-GHEntraFido.ps1 failed on GitHub-hosted runners because it searched $HOME recursively for HtmlAgilityPack.dll — a path that doesn't exist on fresh runners — rather than loading the DLL bundled with the already-installed PSParseHTML module.

Changes

  • Scripts/Export-GHEntraFido.ps1
    • Guard-import PSParseHTML at function entry if not already in session
    • Replace $HOME recursive scan with a targeted lookup under (Get-Module PSParseHTML).ModuleBase:
      if (-not ('HtmlAgilityPack.HtmlDocument' -as [type])) {
          $module = Get-Module PSParseHTML
          $dll = Get-ChildItem -Path $module.ModuleBase -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue |
              Select-Object -First 1
          if (-not $dll) {
              throw "HtmlAgilityPack.dll not found under PSParseHTML module path. Ensure PSParseHTML is installed before running Export-GHEntraFido."
          }
          Add-Type -Path $dll.FullName
      }
    • Remove duplicate Invoke-WebRequest + LoadHtml calls that existed back-to-back in the original
Original prompt

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

Context:

Observed failure:

  • GitHub Actions job merge-fido-data still fails on the PR head commit.
  • Failing job: 75535652792
  • Failure message from logs:
    • Failed to fetch data from URL: HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido.

Root cause still present:

  • Scripts/Export-GHEntraFido.ps1 no longer recursively scans $HOME, but it still directly instantiates HtmlAgilityPack.HtmlDocument.
  • Importing PSParseHTML alone does not guarantee the HtmlAgilityPack type is already resolvable in the session.

Required change:

  • Update Scripts/Export-GHEntraFido.ps1 so it robustly ensures HtmlAgilityPack.HtmlDocument is available after importing PSParseHTML.
  • Preferred minimal approach:
    • Import PSParseHTML if not already loaded.
    • If the type HtmlAgilityPack.HtmlDocument is still unavailable, locate HtmlAgilityPack.dll under the installed PSParseHTML module directory ((Get-Module PSParseHTML).ModuleBase) and load it with Add-Type.
    • Do not scan all of $HOME.
    • Preserve the existing HTML parsing behavior and table extraction logic.
  • Keep the workflow hardening already in the PR unless the agent finds a more targeted improvement.

Acceptance criteria:

  • The script no longer depends on a brittle global file search.
  • The script can run successfully on GitHub-hosted runners where PSParseHTML is installed in the workflow.
  • The PR branch is updated with the targeted patch.
  • After updating, allow GitHub checks to run and report whether the checks still fail or not.

Please update the existing PR branch rather than creating a separate unrelated change.

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

User: Please find a solution for failing job 75535652792. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is caused by Export-GHEntraFido trying to instantiate HtmlAgilityPack.HtmlDocument, but the assembly is not available at runtime:

Solution

Make Export-GHEntraFido.ps1 stop depending on direct construction of the HtmlAgilityPack .NET type. Use the parser already exposed by PSParseHTML, or parse the response HTML with PowerShell-native HTML handling instead of New-Object HtmlAgilityPack.HtmlDocument.

Recommended fix

Replace the HtmlAgilityPack object creation and node traversal in Scripts/Export-GHEntraFido.ps1 with a module-level parser call.

A practical patch is:

Function Export-GHEntraFido {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$Url
    )

    Import-Module PSParseHTML -ErrorAction Stop

    $response = Invoke-WebRequest -Uri $Url
    $htmlContent = $response.Content

    # Parse HTML through the module instead of directly newing HtmlAgilityPack types
    $htmlDocument = ConvertFrom-Html -Content $htmlContent

    $tableNodes = $htmlDocument.SelectNodes("//table")

    $targetTableNode = $null
    foreach ($tableNode in $tableNodes) {
        $headers = $tableNode.SelectNodes(".//thead/tr/th") | ForEach-Object { $_.InnerText.Trim() }
        if ($headers -contains "Description" -and $headers -contains "AAGUID") {
            $targetTableNode = $tableNode
            break
        }
    }

    if ($null -eq $targetTableNode) ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

…ule directory instead of scanning $HOME

Agent-Logs-Url: https://github.com/DevClate/EntraFIDOFinder/sessions/d66739a1-3d9d-43cb-84e0-425eac406af0

Co-authored-by: DevClate <107187714+DevClate@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GitHub Actions failure in merge-fido-data job Fix HtmlAgilityPack.dll resolution: scope lookup to PSParseHTML module directory May 12, 2026
Copilot AI requested a review from DevClate May 12, 2026 09:30
@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
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.

@copilot

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

Request changes

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

The fix has been pushed in commit 77e27a2 on PR #722 (branch copilot/fix-gh-actions-job-failure-again). PR #721 was closed, so the work was continued there. The script now:

  1. Guard-imports PSParseHTML if not already loaded
  2. Checks if HtmlAgilityPack.HtmlDocument is resolvable — if not, locates the DLL under (Get-Module PSParseHTML).ModuleBase and loads it with Add-Type
  3. No longer scans $HOME

Please check PR #722 for the applied changes.

@DevClate DevClate closed this May 12, 2026
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.

2 participants