fix(fragment): guard guid/updates reads with JsonValueKind - #135
Conversation
A non-string "guid" or "updates" value caused JsonElement.GetString() to throw InvalidOperationException, which LoadAll treated as malformed and skipped the whole file. Now each profile entry is individually skipped when its GUID target is not a JSON string, so one bad profile in a fragment no longer discards the rest. Added TerminalFragmentDiscoveryTests.LoadAll_SkipsNonStringGuid_AndProcessesRestOfFile. All 917 tests pass. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
📝 WalkthroughWalkthroughChangesTerminal fragment loading
Agent documentation formatting
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 7 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (7 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Qodo FixerNo findings are available for this PR yet. Findings appear here once Qodo has reviewed the PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@QuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs`:
- Around line 252-256: Strengthen the assertions in the LoadAll test around
TerminalFragmentDiscovery.LoadAll by verifying the earlier valid profile is
retained and profiles keyed by invalid numeric guid/updates identifiers are
absent, or by asserting the exact expected profile count. Keep the existing
later valid-profile assertions while ensuring invalid profiles are confirmed
skipped rather than merely tolerated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7c0523ee-d81c-42c8-b6b1-f8d3c5216b36
📒 Files selected for processing (3)
AGENTS.mdQuickShell.Core.Tests/TerminalFragmentDiscoveryTests.csQuickShell.Core/Services/TerminalFragmentDiscovery.cs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Trackdubllc/Trackdub(manual)tonythethompson/QuickShell(manual)tonythethompson/numan(manual)tonythethompson/dependency-chain-substrate(manual)
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: Analyze C# with CodeQL
- GitHub Check: Performance harness (artifacts)
- GitHub Check: .NET build and test
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{cs,py}
📄 CodeRabbit inference engine (Custom checks)
Keep
SessionWorkflowStagemembers in strictly ascending order:Foundation < MediaLoaded < Transcribed < Diarized < Translated < TtsGenerated. Comparisons must use enum member names rather than raw integer literals. When adding or renumbering members, provide a legacy-compatible JSON converter for old numeric values; when reordering, verify all inequalities across the solution retain their original semantic meaning.
Files:
QuickShell.Core/Services/TerminalFragmentDiscovery.csQuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: Keep namespaces aligned with folders, use nullable and implicit usings, and generally define one type per file.
Leave existing#region agent loginstrumentation blocks intact.
Files:
QuickShell.Core/Services/TerminalFragmentDiscovery.csQuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs
QuickShell.Core/**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
QuickShell.Core/**/*.cs: KeepQuickShell.Corefree of CmdPal SDK dependencies; expose swappable services through interfaces and dependency injection.
Async methods ending inAsyncshould acceptCancellationToken cancellationToken = default; synchronous wrappers should use.GetAwaiter().GetResult().
Files:
QuickShell.Core/Services/TerminalFragmentDiscovery.cs
**/*.{cs,csproj}
📄 CodeRabbit inference engine (AGENTS.md)
Use the established static-versus-DI split: pure logic should be internal static helpers, while swappable dependencies should use interfaces and DI.
Files:
QuickShell.Core/Services/TerminalFragmentDiscovery.csQuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs
QuickShell.Core.Tests/**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
QuickShell.Core.Tests/**/*.cs: Use xUnit, underscore-separated test method names, real services and established seams instead of Moq or FluentAssertions.
Use process-wide test seams such asLaunchExecutorTestEnvironment,FakeShortcutRepository, andAgentCliCatalogoverrides; group tests sharing static seams with[Collection].
Files:
QuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs
🔍 Remote MCP GitHub Copilot
Relevant review context
-
TerminalFragmentDiscoveryis an internal static class that scans Windows Terminal fragment roots, with later roots overriding earlier ones. It also uses a fingerprint of fragment file paths, mtimes, and sizes to avoid a full rescan. -
WtProfilesServicerecomputes that fingerprint and then callsTerminalFragmentDiscovery.LoadAll(_fragmentRoots, out var hadReadFailures). A nearby comment says it only commits fragments and invalidates settings caches when every discovered file reads successfully, so failures in this path can block a refresh. -
The repo already has
QuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs, so this PR’s regression test sits in the existing discovery test area.
🔇 Additional comments (2)
AGENTS.md (1)
24-24: LGTM!Also applies to: 40-40
QuickShell.Core/Services/TerminalFragmentDiscovery.cs (1)
166-175: LGTM!
…ath.Combine' may silently drop its earlier arguments' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Anthony Thompson <github@trackdub.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Anthony Thompson <github@trackdub.com>
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @tonythethompson. The following files were modified: * `QuickShell.Core/Services/TerminalFragmentDiscovery.cs` These files were ignored: * `QuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs` These file types are not supported: * `AGENTS.md`
Summary
Adds a
JsonValueKind.Stringguard before readingguidandupdatesinTerminalFragmentDiscovery.MergeFile. Previously, a non-string value madeJsonElement.GetString()throwInvalidOperationException, whichLoadAllcaught and treated as malformed JSON, causing the entire fragment file to be skipped. Now only the bad profile is skipped and the rest of the file is processed.Changes
QuickShell.Core/Services/TerminalFragmentDiscovery.cs: checkguidNode.ValueKindandupdatesNode.ValueKindbeforeGetString().QuickShell.Core.Tests/TerminalFragmentDiscoveryTests.cs: addLoadAll_SkipsNonStringGuid_AndProcessesRestOfFile.Test plan
dotnet test QuickShell.Core.Tests/QuickShell.Core.Tests.csproj -c Debug -p:Platform=x64passed: 917/917.Generated with Devin
Summary by cubic
Guarded JSON type checks for
guid/updatesinTerminalFragmentDiscoveryso one bad profile no longer skips the whole fragment file; only the invalid entry is ignored.JsonValueKind.StringbeforeGetString()forguid/updatesinTerminalFragmentDiscovery.MergeFile; skip entries with non-string IDs.load_all_skips_non_string_guid_and_processes_rest_of_fileto verify behavior; added XML doc comments forMergeFile.Written for commit 7ad9a69. Summary will update on new commits.