From a735d8c2208318fed8c059221d823048a0789064 Mon Sep 17 00:00:00 2001 From: Howard Enos Date: Sun, 31 May 2026 14:12:30 -0700 Subject: [PATCH] fix(onboarding-diag): jq-normalize single-element facts arrays (cc5dbdfa) PowerShell ConvertTo-Json collapses a single-element array into a bare object (or, for string arrays, a bare string). The runner iterated/joined several facts.* fields, so single-volume / single-NIC / single-admin machines silently dropped the Fixed Volumes table and errored the network adapter, local-administrator, and installed-software-diff lines. Fix jq-side in the runner (backward-compatible with already-written immutable baselines; PS1 untouched per the todo decision) using `if type=="array" then . elif .==null then [] else [.] end` at: volumes, network_adapters (+ inner ip/dns), local_administrators, and installed_software (both sides of the diff). Verified with synthetic single-element JSON and a multi-element no-regression check. Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/scripts/run-onboarding-diagnostic.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.claude/scripts/run-onboarding-diagnostic.sh b/.claude/scripts/run-onboarding-diagnostic.sh index 13c60ea..10a80a2 100644 --- a/.claude/scripts/run-onboarding-diagnostic.sh +++ b/.claude/scripts/run-onboarding-diagnostic.sh @@ -415,21 +415,21 @@ echo "$DIAG_JSON" | jq '.' > "$JSON_PATH" "- **Pending reboot:** " + (($f.pending_reboot // false)|tostring) + "\n" + "- **Installed software count:** " + (($f.installed_software_count // 0)|tostring) + "\n" + "- **Scheduled tasks (non-MS, enabled):** " + (($f.scheduled_tasks_count // 0)|tostring) + "\n" + - "- **Local administrators:** " + (($f.local_administrators // []) | join(", ")) + "- **Local administrators:** " + (($f.local_administrators | if type=="array" then . elif .==null then [] else [.] end) | join(", ")) ' echo "" echo "### Fixed volumes" echo "" echo "$DIAG_JSON" | jq -r ' - (.facts.volumes // []) | .[] | + (.facts.volumes | if type=="array" then . elif .==null then [] else [.] end) | .[] | "- " + (.drive // "?") + " - " + ((.free_gb // 0)|tostring) + " GB free of " + ((.size_gb // 0)|tostring) + " GB (" + ((.free_pct // 0)|tostring) + "%)" ' echo "" echo "### Network adapters" echo "" echo "$DIAG_JSON" | jq -r ' - (.facts.network_adapters // []) | .[] | - "- " + (.description // "?") + " - IP: " + ((.ip // []) | join(", ")) + " - DNS: " + ((.dns // []) | join(", ")) + " - DHCP: " + ((.dhcp // false)|tostring) + (.facts.network_adapters | if type=="array" then . elif .==null then [] else [.] end) | .[] | + "- " + (.description // "?") + " - IP: " + ((.ip | if type=="array" then . elif .==null then [] else [.] end) | join(", ")) + " - DNS: " + ((.dns | if type=="array" then . elif .==null then [] else [.] end) | join(", ")) + " - DHCP: " + ((.dhcp // false)|tostring) ' echo "" @@ -504,15 +504,15 @@ echo "$DIAG_JSON" | jq '.' > "$JSON_PATH" SW_ADDED="$(jq -n \ --slurpfile cur "$JSON_PATH" \ --slurpfile old "$PRIOR_JSON" ' - ((($old[0].facts.installed_software // []) | map(.name)) | unique) as $o | - ((($cur[0].facts.installed_software // []) | map(.name)) | unique) as $c | + ((($old[0].facts.installed_software | if type=="array" then . elif .==null then [] else [.] end) | map(.name)) | unique) as $o | + ((($cur[0].facts.installed_software | if type=="array" then . elif .==null then [] else [.] end) | map(.name)) | unique) as $c | [ $c[] | select(. as $n | ($o | index($n)) | not) ] ')" SW_REMOVED="$(jq -n \ --slurpfile cur "$JSON_PATH" \ --slurpfile old "$PRIOR_JSON" ' - ((($old[0].facts.installed_software // []) | map(.name)) | unique) as $o | - ((($cur[0].facts.installed_software // []) | map(.name)) | unique) as $c | + ((($old[0].facts.installed_software | if type=="array" then . elif .==null then [] else [.] end) | map(.name)) | unique) as $o | + ((($cur[0].facts.installed_software | if type=="array" then . elif .==null then [] else [.] end) | map(.name)) | unique) as $c | [ $o[] | select(. as $n | ($c | index($n)) | not) ] ')"