feat: add sanitized diagnostics log bundle#562
Conversation
- Add diagnostics export redactor for tokens, IDs, paths, cookies, webhooks, and provider secrets - Include sanitized tray, JSONL, crash, setup, and connection event log tails in diagnostics bundles - Replace diagnostics save with native Win32 save dialog for self-hosted WinUI - Add regression tests for redaction and bundle safety Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Codex review: needs changes before merge. Reviewed June 26, 2026, 12:49 PM ET / 16:49 UTC. Summary Reproducibility: yes. for the PR defects: downloaded proof artifacts show /home/openclaw paths in exported bundles, and PR-head source only redacts /Users-style Unix paths. The stale-cache issue is source-reproducible from BuildCached and CreateStateSignature using only collection counts for several diagnostic sections. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Keep the bounded, side-effect-free export design, add Linux home-directory redaction and cache invalidation coverage, then return the repaired PR to maintainer privacy-boundary review. Do we have a high-confidence way to reproduce the issue? Yes for the PR defects: downloaded proof artifacts show /home/openclaw paths in exported bundles, and PR-head source only redacts /Users-style Unix paths. The stale-cache issue is source-reproducible from BuildCached and CreateStateSignature using only collection counts for several diagnostic sections. Is this the best way to solve the issue? No; the side-effect-free bounded export direction is the right shape, but the implementation must repair Linux home-path redaction and cache invalidation before it is the safest maintainable solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1c377cb64b65. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
ClawSweeper PR egg 🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
- Restore direct debug-bundle copy/deep-link path to generated summaries only - Update Diagnostics page copy to clarify summary-only clipboard behavior - Add contract tests preventing log-tail bundles from bypassing preview Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a sanitized “diagnostics bundle” export flow for the WinUI tray app, including robust redaction of secrets/identifiers and expanded bundle contents (log tails + structured diagnostics + crash/setup tails + connection timeline), along with new regression tests and a Win32-native “Save as” dialog for self-hosted WinUI.
Changes:
- Introduce
DiagnosticsExportRedactorand apply it to bundle generation and log tail reading (including final “whole-bundle” sanitization). - Add
DiagnosticsBundleBuilder+DiagnosticsLogTailReaderand update the debug/diagnostics UI to preview/copy/save the sanitized bundle. - Add new Shared/Tray tests covering redaction shapes, split-line secrets, missing files behavior, and bundle safety guarantees.
Show a summary per file
| File | Description |
|---|---|
| tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj | Links new WinUI diagnostics services/helpers into Tray test project. |
| tests/OpenClaw.Tray.Tests/DiagnosticsPageContractTests.cs | Adds contract tests to enforce “summary-only vs full bundle” UX boundaries. |
| tests/OpenClaw.Tray.Tests/DiagnosticsBundleBuilderTests.cs | Adds tests for bundle contents, missing-file behavior, and split-line redaction. |
| tests/OpenClaw.Shared.Tests/DiagnosticsExportRedactorTests.cs | Adds broad regression coverage for redaction patterns and context preservation. |
| src/OpenClaw.Tray.WinUI/Windows/DiagnosticsBundleDialog.xaml.cs | Reworks Save flow to use Win32 picker + deferral so errors surface in UI. |
| src/OpenClaw.Tray.WinUI/Windows/DiagnosticsBundleDialog.xaml | Replaces InfoBar with a custom “review before sharing” card-style header. |
| src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw | Updates strings for “summary debug bundle” and new dialog header UIDs. |
| src/OpenClaw.Tray.WinUI/Strings/fr-fr/Resources.resw | Same localization updates as en-us. |
| src/OpenClaw.Tray.WinUI/Strings/nl-nl/Resources.resw | Same localization updates as en-us. |
| src/OpenClaw.Tray.WinUI/Strings/zh-cn/Resources.resw | Same localization updates as en-us. |
| src/OpenClaw.Tray.WinUI/Strings/zh-tw/Resources.resw | Same localization updates as en-us. |
| src/OpenClaw.Tray.WinUI/Services/DiagnosticsLogTailReader.cs | Adds sanitized + truncated log tail reader for bundle sections. |
| src/OpenClaw.Tray.WinUI/Services/DiagnosticsClipboardService.cs | Renames “debug bundle” copy label to “summary debug bundle”. |
| src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs | Adds full bundle builder composing summaries, timeline, and sanitized tails. |
| src/OpenClaw.Tray.WinUI/Pages/DebugPage.xaml.cs | Wires diagnostics bundle preview flow and copy actions. |
| src/OpenClaw.Tray.WinUI/Pages/DebugPage.xaml | Updates UX copy to “Copy summary debug bundle” with exclusions noted. |
| src/OpenClaw.Tray.WinUI/Helpers/Win32FilePickerHelper.cs | Adds Win32 Save dialog via COM IFileSaveDialog on STA thread. |
| src/OpenClaw.Tray.WinUI/App.xaml.cs | Exposes recent connection diagnostic events for bundling. |
| src/OpenClaw.Shared/DiagnosticsExportRedactor.cs | Adds centralized regex-based redaction for bundles/log exports. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 19/19 changed files
- Comments generated: 9
- Keep Diagnostics page summary-copy action summary-only - Strengthen contract tests for the preview-only log-tail boundary - Destroy native save-dialog filter spec before freeing unmanaged memory - Remove unused diagnostics InfoBar localization resources - Update no-HWND save diagnostic message to match Desktop fallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
This direction makes sense for a shareable diagnostics bundle, but the redactor is carrying a lot of regex responsibility in one place. I would not block solely because it uses regex — conservative over-redaction is probably right here — but I think it needs a maintainability/perf pass before merge: group the rules by threat class, consider source-generated regexes or clearly named rule objects, and add a worst-case/perf regression test so a long log line or malformed URL/token cannot cause pathological backtracking. The current test coverage for common secret shapes is good; my concern is mostly long-term maintainability and worst-case behavior. |
|
I took a closer pass on the redaction implementation. The feature is valuable and regex is not inherently the wrong tool for free-form diagnostics, but I think this needs a small reliability/perf cleanup before merge. Concrete concerns:
Longer-term, because this is |
Resolve the old diagnostics bundle PR against current main and refactor the privacy boundary so diagnostics are sanitized at write/record time where possible, with export redaction kept as defense-in-depth. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Decode common JSON escape sequences before export redaction while keeping plain log paths stable. Add fail-closed timeout handling for bundle sanitization and regression tests for nested escapes and timeout sentinels. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the diagnostics bundle click handler on the guarded async path while preventing duplicate preview launches. Yield before showing the ContentDialog so it starts from a clean UI dispatch turn. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Show the diagnostics bundle dialog immediately with a preparing state while building the bundle off the UI thread. Disable copy/save until the bundle text is ready and avoid repeated legacy log normalization work after a file has already been migrated in the current process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reserve the diagnostics bundle preview viewport before async bundle text arrives so the dialog does not resize from the loading state. Track persisted-log normalization by file signature so modified files are still migrated while unchanged files are not rescanned repeatedly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse recently generated diagnostics bundles, key longer-lived reuse by source/state signatures, and read log tails from the end of files instead of scanning full logs. Preserve the diagnostics dialog layout fix and log guarded UI exceptions with full exception details. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve diagnostics redaction and preview conflicts after upstream changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid reparenting JSON nodes while normalizing structured setup logs and preserve non-secret request IDs while keeping PII redaction intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Christine, I think the diagnostics bundle feature is valuable, but I do not think this PR is safe to merge in its current shape. I would recommend redesigning it around a smaller, side-effect-free export pipeline rather than continuing to patch this version. The main concern is the privacy/performance boundary. I think the safer design is:
A smaller salvageable v1 would be: remove persisted-log normalization, keep only bounded tail export, sanitize every emitted line/string at export time, route all copy/save actions through that path, and include perf/timeout tests. Once that is solid, source-side sanitization can still be improved separately, but export must remain a defense-in-depth boundary rather than assuming logs are already safe. |
Refactor diagnostics bundle generation to tail bounded source sections, sanitize during export, and route copy/export surfaces through the same side-effect-free redaction path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Route recent-log and about-page copy paths through the export sanitizer, and retain bounded context before the visible tail so multiline secrets redact before emission. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Route the connection timeline diagnostic copy surface through the export sanitizer so all diagnostics copy paths share the same defense-in-depth redaction boundary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Keep summary diagnostics copy paths summary-only, handle setup log enumeration failures inside bundle generation, and avoid rewriting legacy chat metadata caches unless new tool metadata is actually persisted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
diagnostics bundle preview, with PII sanitized: full diagnostics bundle, copied and pasted: full diagnostics bundle .txt, after clicking "save to file" summary bundle: |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Preserve connection timeline ISO timestamps in diagnostics bundles and align the summary debug copy text with the summary-only clipboard output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Redact Linux home-directory paths in diagnostics output and remove unsafe diagnostics bundle reuse so state changes with unchanged collection counts regenerate current bundle text. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>




Summary
DiagnosticsExportRedactorkept as defense-in-depth for older/raw export text.\u0022and escaped CRLFs before final redaction, while keeping plain Windows paths stable and guarding control/backslash unicode escapes.[REDACTED_SANITIZER_TIMEOUT]instead of aborting export.Validation
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~DiagnosticsExportRedactorTestsdotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter "FullyQualifiedName~DiagnosticsBundleBuilderTests|FullyQualifiedName~DiagnosticsPageContractTests".\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restoregit diff --check