Fix cross-platform backups and refresh policy validation - #32
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR fixes a strict-mode crash on Linux and macOS where
Confidence Score: 5/5Safe to merge. The changes are narrowly scoped: a one-property addition to four return sites in Get-PolicyValue, a BOM-free writer replacing Set-Content, updated tests, and a version bump. All changed code paths in PlatformPolicy.ps1 correctly add ReadError = $false to match the Registry branch shape, eliminating the strict-mode property-access failure during Linux/macOS backup creation. The Set-Utf8NoBomText function is straightforward, and its Resolve-Path call is always satisfied because both target files are read before being written. The new tests directly exercise both the backup path and the BOM-free output, giving good regression coverage. No files require special attention. The most behaviorally significant change is in src/PlatformPolicy.ps1, and its correctness is directly confirmed by the updated Test-Behavior.ps1 Linux backup assertions. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Script as Invoke-BraveDebloat.ps1
participant PP as PlatformPolicy.ps1
participant FS as File System
Script->>PP: "Get-PolicyTarget(Platform=Linux)"
PP-->>Script: "Target{Kind=JsonFile, Path=...}"
Note over Script,PP: applyChanges=true, NoBackup=false
Script->>PP: New-Backup → Get-PolicySnapshot
loop each policy name
PP->>PP: Get-PolicyValue(Target, PolicyName)
Note over PP: Before fix: no ReadError property → strict-mode crash<br/>After fix: ReadError = $false on all non-Registry branches
PP-->>PP: "{Exists, Value, Kind, ReadError=$false}"
end
PP->>FS: "Write BraveDebloater-*.json backup"
FS-->>PP: backup path
PP-->>Script: backup path
Script->>FS: Log Backup written to ...
Script->>PP: Set-PolicyValue (writes JsonFile policy)
PP->>FS: Write BraveDebloater.json policy
Note over Script,FS: Update-PolicyTemplateVersion.ps1 path
Script->>FS: Get-Content -Raw (reads file, PS5.1 strips BOM)
Script->>Script: Regex replace policyTemplateVersion
Script->>FS: Set-Utf8NoBomText → WriteAllText(UTF8NoBom)
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Script as Invoke-BraveDebloat.ps1
participant PP as PlatformPolicy.ps1
participant FS as File System
Script->>PP: "Get-PolicyTarget(Platform=Linux)"
PP-->>Script: "Target{Kind=JsonFile, Path=...}"
Note over Script,PP: applyChanges=true, NoBackup=false
Script->>PP: New-Backup → Get-PolicySnapshot
loop each policy name
PP->>PP: Get-PolicyValue(Target, PolicyName)
Note over PP: Before fix: no ReadError property → strict-mode crash<br/>After fix: ReadError = $false on all non-Registry branches
PP-->>PP: "{Exists, Value, Kind, ReadError=$false}"
end
PP->>FS: "Write BraveDebloater-*.json backup"
FS-->>PP: backup path
PP-->>Script: backup path
Script->>FS: Log Backup written to ...
Script->>PP: Set-PolicyValue (writes JsonFile policy)
PP->>FS: Write BraveDebloater.json policy
Note over Script,FS: Update-PolicyTemplateVersion.ps1 path
Script->>FS: Get-Content -Raw (reads file, PS5.1 strips BOM)
Script->>Script: Regex replace policyTemplateVersion
Script->>FS: Set-Utf8NoBomText → WriteAllText(UTF8NoBom)
Reviews (1): Last reviewed commit: "Fix cross-platform backups and refresh v..." | Re-trigger Greptile |
Summary
Get-PolicyValuereturn a consistent snapshot shape on Linux and macOS so strict-mode backup creation no longer fails on the missingReadErrorproperty before policy writes.150.1.94.57, keep updater output UTF-8 without BOM, and pin the remaining checkout steps to the reviewed v5.0.1 commit.Link to Devin session: https://app.devin.ai/sessions/c1632e2d7a214e65950180394f66fb9a
Requested by: @osfv