Skip to content

Fix the Store search suggestion undo, which never worked - #78

Merged
BiosSystem merged 1 commit into
masterfrom
feature/fix-store-suggestions-undo
Sep 24, 2026
Merged

BiosSystem merged 1 commit into
masterfrom
feature/fix-store-suggestions-undo

Conversation

@BiosSystem

Copy link
Copy Markdown
Owner

Undoing DisableStoreSearchSuggestions failed on every run. EnableStoreSearchSuggestions filtered the ACL with (try { ... } catch { $false }); inside plain parentheses Windows PowerShell parses try as a command name, so the filter threw "The term 'try' is not recognized" as soon as it reached the Everyone deny rule the apply had added. The rule was never removed, and Remove-Item on store.db was then refused with access denied, so the undo threw. Fix: $(try ...), which accepts statements (verified on PS 5.1).

Found by a new static check

A call-graph scan of all 97 scripts Winnow loads (2,382 command calls) resolved every call except this one. Two checks now run in Test-SafetyGuards:

  • no PowerShell keyword is invoked as a command;
  • every call resolves to a Winnow function, a cmdlet or alias, or a listed external program (winget, DISM, reg, netsh, takeown, icacls, powercfg, bcdedit), so a new shell-out has to be added deliberately.

Tests

  • New Tests/Unit/Test-StoreSearchSuggestions.ps1 (wired into CI): disable then undo against a real temp file; asserts no ACL warning and the file removed. takeown/icacls are mocked.
  • Against the old code the new tests fail exactly 3 times: the undo test with the same access-denied error, and both guards pointing at StoreSearchSuggestions.ps1:163. With the fix: pass.
  • Local: static validation clean (134 files), Tests\Unit 209 passed / 0 failed, standalone rebuilt, every unit file wired into test.yml.
  • Not run: the live undo on a machine with the Store installed (Windows Sandbox has no Store).

The undo removes the Everyone deny rule that disabling puts on each user's
store.db, then deletes the file. The rule check wrapped a try statement in
plain parentheses, which Windows PowerShell parses as a call to a command
named try. It threw on every undo, so the deny rule stayed and deleting the
file was refused with access denied: the feature could not be reverted.
Use a subexpression, which accepts statements.

Test-StoreSearchSuggestions.ps1 runs disable and undo against a real file
and fails on the old code with the same access-denied error.

Add two checks over every script Winnow loads: no PowerShell keyword may be
invoked as a command, and every call must resolve to a Winnow function, a
cmdlet or alias, or a listed external program. The second found this bug;
nothing else in the codebase calls a missing command.
@BiosSystem
BiosSystem merged commit ec845a3 into master Sep 24, 2026
1 check passed
@BiosSystem
BiosSystem deleted the feature/fix-store-suggestions-undo branch September 24, 2026 14:30
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.

1 participant