Skip to content

chore: Keep RPC boolean metadata validation strict - #1597

Merged
hatayama merged 4 commits into
v3-betafrom
feature/hatayama/strict-rpc-boolean-metadata
Jul 8, 2026
Merged

hatayama merged 4 commits into
v3-betafrom
feature/hatayama/strict-rpc-boolean-metadata

Conversation

@hatayama

@hatayama hatayama commented Jul 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Keep malformed boolean metadata from being treated as enabled flags across JSON-RPC request paths.
  • Share the strict boolean reader used by envelope feature flags with compile request metadata parsing.

User Impact

  • Requests that send strings such as "true" or "false" for boolean metadata continue to fail closed instead of changing request behavior.
  • Boolean metadata handling is now less likely to drift between request paths.

Changes

  • Added a shared strict JSON boolean metadata reader.
  • Reused it for envelope feature flags and compile reload-wait metadata.
  • Added focused EditMode tests for strict boolean parsing and case-sensitive/case-insensitive lookup behavior.

Verification

  • dist/darwin-arm64/uloop clear-console --project-path "$(git rev-parse --show-toplevel)"
  • dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"
  • dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "(StrictJsonBooleanMetadataReaderTests|JsonRpcRequestProcessorCliVersionGateTests)"

Review in cubic

Centralize optional JSON boolean metadata handling so envelope feature flags and compile reload-wait params reject coerced values through the same reader.
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ec04901e-8d44-4ca2-8e7b-b671c0b4bbe2

📥 Commits

Reviewing files that changed from the base of the PR and between ce3d749 and 7e3366a.

📒 Files selected for processing (2)
  • Assets/Tests/Editor/UnityCliLoopToolRegistryTests.cs
  • Packages/src/Editor/Infrastructure/Api/GetToolDetailsBridgeCommand.cs

📝 Walkthrough

Walkthrough

A 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.

Changes

Strict Boolean Metadata and Tool-Details Flag

Layer / File(s) Summary
Strict boolean reader and tests
Packages/src/Editor/Infrastructure/Api/StrictJsonBooleanMetadataReader.cs, Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs
Adds ReadOptionalBoolean and tests its boolean, string, missing, case-insensitive, and null-metadata cases.
Metadata readers use shared parsing
Packages/src/Editor/Infrastructure/Api/JsonRpcCompileRequestMetadataReader.cs, Packages/src/Editor/Infrastructure/Api/UloopEnvelope.cs
Routes existing boolean metadata reads through the shared optional boolean helper.
GetToolDetails development-only flag
Packages/src/Editor/Infrastructure/Api/GetToolDetailsBridgeCommand.cs, Assets/Tests/Editor/UnityCliLoopToolRegistryTests.cs
Reads IncludeDevelopmentOnly with the shared helper and adds coverage for development-only tool inclusion and exclusion cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: stricter RPC boolean metadata validation.
Description check ✅ Passed The description matches the changes, including the shared strict boolean reader, reused call sites, and added tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/hatayama/strict-rpc-boolean-metadata

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs (1)

13-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing test for metadata == null.

The reader's null-metadata early return (line 18-21 of StrictJsonBooleanMetadataReader.cs) is a real production path: UloopEnvelope.ReadMetadata returns null when the "uloop" property is absent/non-object, and that null is passed straight into ReadOptionalBoolean via ReadStrictBooleanMetadata. None of the four tests here exercise that branch — add a case asserting ReadOptionalBoolean(null, "enabled", StringComparison.Ordinal) returns null.

✅ 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

📥 Commits

Reviewing files that changed from the base of the PR and between be39312 and bac7bb5.

⛔ Files ignored due to path filters (2)
  • Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Infrastructure/Api/StrictJsonBooleanMetadataReader.cs.meta is excluded by none and included by none
📒 Files selected for processing (4)
  • Assets/Tests/Editor/StrictJsonBooleanMetadataReaderTests.cs
  • Packages/src/Editor/Infrastructure/Api/JsonRpcCompileRequestMetadataReader.cs
  • Packages/src/Editor/Infrastructure/Api/StrictJsonBooleanMetadataReader.cs
  • Packages/src/Editor/Infrastructure/Api/UloopEnvelope.cs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Re-trigger cubic

Add the missing null-metadata regression test for the shared JSON-RPC boolean metadata reader.
@hatayama

hatayama commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

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.
@hatayama

hatayama commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

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.
@hatayama
hatayama merged commit 770eb2f into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the feature/hatayama/strict-rpc-boolean-metadata branch July 8, 2026 04:53
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