From 3a132968c7b405f95db88875d8fd6f8a67a24548 Mon Sep 17 00:00:00 2001 From: Brad Lance Date: Sun, 5 Jul 2026 20:10:04 -0500 Subject: [PATCH] Let practice.json add fields entity.json doesn't have, not just replace them Merge-Config assigned override values with '=', which throws SetValueInvocationException when the property doesn't exist on the base object - so a practice.json could only override fields already present in entity.json. AJMATS's practice.json supplies insurance_path/pdf_path that CAMBS's entity.json lacks entirely, which crashed the merge. Use Add-Member -Force (handles both add and replace), copy whole sections missing from the base, skip _comment keys, and replace scalar sections directly. --- engine.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine.ps1 b/engine.ps1 index 4b363df..5e5b95d 100644 --- a/engine.ps1 +++ b/engine.ps1 @@ -97,10 +97,16 @@ function Merge-Config($base, $override) { if (-not $override) { return $base } $merged = $base | ConvertTo-Json -Depth 10 | ConvertFrom-Json foreach ($section in $override.PSObject.Properties) { - if ($null -ne $merged.PSObject.Properties[$section.Name]) { + if ($section.Name -like "_*") { continue } + $baseSection = $merged.PSObject.Properties[$section.Name] + if ($null -eq $baseSection) { + $merged | Add-Member -NotePropertyName $section.Name -NotePropertyValue $section.Value + } elseif ($section.Value -is [System.Management.Automation.PSCustomObject]) { foreach ($prop in $section.Value.PSObject.Properties) { - $merged.$($section.Name).$($prop.Name) = $prop.Value + $merged.$($section.Name) | Add-Member -NotePropertyName $prop.Name -NotePropertyValue $prop.Value -Force } + } else { + $merged.$($section.Name) = $section.Value } } return $merged