Repository navigation
chore: Keep RPC boolean metadata validation strict - #1597
Conversation
Centralize optional JSON boolean metadata handling so envelope feature flags and compile reload-wait params reject coerced values through the same reader.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA shared optional-boolean reader was added and adopted by existing JSON metadata readers. Get-tool-details now reads the development-only flag through the same helper, and tests cover boolean, string, missing, null, and case-handling behavior. ChangesStrict Boolean Metadata and Tool-Details Flag
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs (1)
13-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing test for
metadata == null.The reader's null-metadata early return (line 18-21 of
StrictJsonBooleanMetadataReader.cs) is a real production path:UloopEnvelope.ReadMetadatareturnsnullwhen the"uloop"property is absent/non-object, and thatnullis passed straight intoReadOptionalBooleanviaReadStrictBooleanMetadata. None of the four tests here exercise that branch — add a case assertingReadOptionalBoolean(null, "enabled", StringComparison.Ordinal)returnsnull.✅ Suggested additional test
[Test] public void ReadOptionalBoolean_WhenPropertyIsMissing_ReturnsNull() { // Verifies absent optional flags stay unknown for callers that choose their own default. JObject metadata = JObject.Parse("{}"); bool? value = StrictJsonBooleanMetadataReader.ReadOptionalBoolean( metadata, "enabled", System.StringComparison.Ordinal); Assert.That(value, Is.Null); } + + [Test] + public void ReadOptionalBoolean_WhenMetadataIsNull_ReturnsNull() + { + // Verifies the reader tolerates an absent metadata object (e.g. missing "uloop" envelope). + bool? value = StrictJsonBooleanMetadataReader.ReadOptionalBoolean( + null, + "enabled", + System.StringComparison.Ordinal); + + Assert.That(value, Is.Null); + }🤖 Prompt for 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. In `@Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs` around lines 13 - 67, Add a test in StrictJsonBooleanMetadataReaderTests for the null-metadata path: verify that calling StrictJsonBooleanMetadataReader.ReadOptionalBoolean with a null JObject, the "enabled" key, and StringComparison.Ordinal returns null. This should cover the early return branch used by ReadStrictBooleanMetadata/UloopEnvelope.ReadMetadata when metadata is absent or not an object, alongside the existing boolean, string, case-insensitive, and missing-property cases.
🤖 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.
Nitpick comments:
In `@Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs`:
- Around line 13-67: Add a test in StrictJsonBooleanMetadataReaderTests for the
null-metadata path: verify that calling
StrictJsonBooleanMetadataReader.ReadOptionalBoolean with a null JObject, the
"enabled" key, and StringComparison.Ordinal returns null. This should cover the
early return branch used by ReadStrictBooleanMetadata/UloopEnvelope.ReadMetadata
when metadata is absent or not an object, alongside the existing boolean,
string, case-insensitive, and missing-property cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3e439564-1526-4291-bcfe-a2a28cf39303
⛔ Files ignored due to path filters (2)
Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs.metais excluded by none and included by nonePackages/src/Editor/Infrastructure/Api/StrictJsonBooleanMetadataReader.cs.metais excluded by none and included by none
📒 Files selected for processing (4)
Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.csPackages/src/Editor/Infrastructure/Api/JsonRpcCompileRequestMetadataReader.csPackages/src/Editor/Infrastructure/Api/StrictJsonBooleanMetadataReader.csPackages/src/Editor/Infrastructure/Api/UloopEnvelope.cs
Add the missing null-metadata regression test for the shared JSON-RPC boolean metadata reader.
|
Addressed CodeRabbit's null-metadata test nitpick in ce3d749 by adding a regression test that verifies StrictJsonBooleanMetadataReader.ReadOptionalBoolean returns null when the metadata object is absent. |
Reuse the shared JSON boolean metadata reader for the tool catalog development-only flag so string values are not coerced into enabled access.
|
Addressed fable5's review finding in 197a6c4 by moving the get-tool-details development-only flag to StrictJsonBooleanMetadataReader and adding catalog tests that verify real booleans are accepted while string values are not coerced. |
Align the final strict boolean parsing changes with review style feedback before merging.
Summary
User Impact
Changes
Verification