PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

CmdPal: GEH per partes; part 1: error report builder, sanitizer and internals tools setting page

Open jiripolasek opened this issue 2 weeks ago • 4 comments

Summary of the Pull Request

This PR adds three parts of the original big bad global error handler (error report builder, sanitization and internal tools UI).

Error Report Generation

  • ErrorReportBuilder: Produces a detailed, technical report with system context.
  • Comprehensive data: OS version, architecture, culture, app version, elevation status, etc.
  • Exception analysis: Coalesces nested exception messages and HRESULT details for clearer diagnostics.
Example

This is an error report generated by Windows Command Palette. If you are seeing this, it means something went a little sideways in the app. You can help us fix it by filing a report at https://aka.ms/powerToysReportBug.

(While you’re at it, give the details below a quick skim — just to make sure there’s nothing personal you’d prefer not to share. It’s rare, but sometimes little surprises sneak in.)

Summary: Message: Test exception; thrown from the UI thread Type: System.NotImplementedException Source: Microsoft.CmdPal.UI Time: 2025-08-25 18:54:44.3854569 HRESULT: 0x80004001 (-2147467263) Context: MainThreadException

Application: App version: 0.0.1.0 Is elevated: no

Environment: OS version: Microsoft Windows 10.0.26120 OS architecture: X64 Runtime identifier: win-x64 Framework: .NET 9.0.8 Process architecture: X64 Culture: cs-CZ UI culture: en-US

Stack Trace: at Microsoft.CmdPal.UI.Settings.InternalPage.ThrowPlainMainThreadException_Click(Object sender, RoutedEventArgs e) at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, RoutedEventArgs e) at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)

------------------ Full Exception Details ------------------ System.NotImplementedException: Test exception; thrown from the UI thread at Microsoft.CmdPal.UI.Settings.InternalPage.ThrowPlainMainThreadException_Click(Object sender, RoutedEventArgs e) at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, RoutedEventArgs e) at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)

============================================================

Real-world example: #41362

PII Sanitization Framework

  • ErrorReportSanitizer: Multi-layer sanitization pipeline for sensitive data.
  • Nine specialized rule providers:
    • PiiRuleProvider: Personally identifiable information (emails, phone numbers, SSNs).
    • ProfilePathAndUsernameRuleProvider: Windows user profiles and usernames.
    • NetworkRuleProvider: IP addresses, MAC addresses, network identifiers.
    • SecretKeyValueRulesProvider: API keys, tokens, passwords in key/value formats.
    • FilenameMaskRuleProvider: Sensitive file paths and extensions.
    • UrlRuleProvider: URLs and web addresses.
    • TokenRuleProvider: JWT and other auth tokens.
    • ConnectionStringRuleProvider: Database connection strings.
    • EnvironmentPropertiesRuleProvider: Environment variables and system properties.

Internals Tools Page

A page in settings available in non-CI-builds:

image

PR Checklist

  • [ ] Closes: #xxx
  • [ ] Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • [ ] Tests: Added/updated and all pass
  • [ ] Localization: All end-user-facing strings can be localized
  • [ ] Dev docs: Added/updated
  • [ ] New binaries: Added on the required places
  • [ ] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

jiripolasek avatar Dec 07 '25 20:12 jiripolasek

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (31)
contoso
Fmy
FNFUROf
Gci
IDTn
Iiwibm
Ikp
Ikpva
Imlhd
Jhb
JIUz
jkl
Jzd
KMUFs
LOCALAPPLICATIONDATA
mno
MTUx
mydb
NTY
ODkw
OTAy
postgre
pqr
Rta
Ryd
Smq
ssw
userdb
WIi
XVCJ
ZSI
These words are not needed and should be removed CLITo CVS Notavailable

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:jiripolasek/PowerToys.git repository on the feature/41606-cmdpal-error-report-builder-and-sanitation branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/20009716041/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Pattern suggestions :scissors: (2)

You could add these patterns to .github/actions/spell-check/patterns.txt:

# Automatically suggested patterns

# hit-count: 2 file-count: 1
# base64 encoded json
\beyJ[-a-zA-Z=;:/0-9+]+

# hit-count: 1 file-count: 1
# regex choice
\(\?:[^)]+\|[^)]+\)

Alternatively, if a pattern suggestion doesn't make sense for this project, add a # to the beginning of the line in the candidates file with the pattern to stop suggesting it.

Notices :information_source: (1)

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

:information_source: Notices Count
:information_source: candidate-pattern 2

See :information_source: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Dec 07 '25 20:12 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (31)
contoso
Fmy
FNFUROf
Gci
IDTn
Iiwibm
Ikp
Ikpva
Imlhd
Jhb
JIUz
jkl
Jzd
KMUFs
LOCALAPPLICATIONDATA
mno
MTUx
mydb
NTY
ODkw
OTAy
postgre
pqr
Rta
Ryd
Smq
ssw
userdb
WIi
XVCJ
ZSI
These words are not needed and should be removed CLITo CVS Notavailable

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:jiripolasek/PowerToys.git repository on the feature/41606-cmdpal-error-report-builder-and-sanitation branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/20010018696/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Pattern suggestions :scissors: (2)

You could add these patterns to .github/actions/spell-check/patterns.txt:

# Automatically suggested patterns

# hit-count: 2 file-count: 1
# base64 encoded json
\beyJ[-a-zA-Z=;:/0-9+]+

# hit-count: 1 file-count: 1
# regex choice
\(\?:[^)]+\|[^)]+\)

Alternatively, if a pattern suggestion doesn't make sense for this project, add a # to the beginning of the line in the candidates file with the pattern to stop suggesting it.

Notices :information_source: (1)

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

:information_source: Notices Count
:information_source: candidate-pattern 2

See :information_source: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Dec 07 '25 20:12 github-actions[bot]

/azp run

jiripolasek avatar Dec 07 '25 23:12 jiripolasek

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 07 '25 23:12 azure-pipelines[bot]