Skip to content

Guard Microsoft Update Catalog row parsing against null table cells - #25

Merged
OSDeploy merged 2 commits into
mainfrom
copilot/fix-null-value-expression-warning
Oct 1, 2026
Merged

OSDeploy merged 2 commits into
mainfrom
copilot/fix-null-value-expression-warning

Conversation

Copilot AI commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Deploying with Deploy-OSDCloud -CLI could emit You cannot call a method on a null-value expression during Microsoft Update Catalog driver lookups. The failure path was triggered by unexpected/malformed catalog rows being parsed without null checks.

  • Root cause

    • Get-MicrosoftUpdateCatalogResult assumed every row had expected <td> nodes and called .InnerText.Trim() directly.
  • Code changes

    • Added defensive cell extraction in base filtering:
      • Skip rows when SelectNodes("td") is null or has fewer than required cells.
      • Read fields via safe string casts instead of direct method calls on potentially null values.
    • Added the same guard in architecture filtering to avoid null access on sparse rows.
  • Behavioral impact

    • Malformed/incomplete catalog rows are ignored instead of surfacing runtime null-method warnings.
    • Existing filtering behavior for valid rows is unchanged.
$cells = $_.SelectNodes("td")
if ($null -eq $cells -or $cells.Count -lt 4) {
    return $false
}

$title = [string]$cells[1].InnerText
$classification = [string]$cells[3].InnerText

Copilot AI changed the title [WIP] Fix warning: cannot call method on a null-value expression Guard Microsoft Update Catalog row parsing against null table cells Aug 1, 2026
Copilot AI requested a review from OSDeploy August 1, 2026 06:04
@OSDeploy
OSDeploy marked this pull request as ready for review October 1, 2026 17:29
Copilot AI balanced review requested due to automatic review settings October 1, 2026 17:29
@OSDeploy
OSDeploy merged commit 6bb2fad into main Oct 1, 2026
@OSDeploy
OSDeploy deleted the copilot/fix-null-value-expression-warning branch October 1, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Incomplete rows can still reach object construction, and classification whitespace handling regresses.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Hardens Microsoft Update Catalog parsing against malformed rows during driver lookup.

Changes:

  • Adds cell-count guards during base and architecture filtering.
  • Uses null-safe string conversion for extracted fields.
File Description
OSDCloud/​private/​microsoft-update-catalog/​Get-MicrosoftUpdateCatalogResult.ps1 Adds defensive catalog-row parsing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

$title = $_.SelectNodes("td")[1].InnerText.Trim()
$classification = $_.SelectNodes("td")[3].InnerText.Trim()
$cells = $_.SelectNodes("td")
if ($null -eq $cells -or $cells.Count -lt 4) {
}

$title = [string]$cells[1].InnerText
$classification = [string]$cells[3].InnerText
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.

Warning: You cannot call a method on a null-value expression

3 participants