Skip to content

[claude] Enforce required members when deserializing commits - #152

Open
myieye wants to merge 3 commits into
mainfrom
claude/enforce-commit-required-members
Open

myieye wants to merge 3 commits into
mainfrom
claude/enforce-commit-required-members

Conversation

@myieye

@myieye myieye commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

[Claude, autonomous]

Fixes #104: the [SetsRequiredMembers] added to the [JsonConstructor] ctors in e500757 made System.Text.Json skip required-member checks, so a commit without clientId or hybridDateTime deserialized with defaults (empty GUID / null). Removes those attributes; the private parameterless ServerCommit ctor for the downstream gql issue stays.

  • Lexbox's new ServerCommit(...) calls all use the public (Guid id) ctor, which is unchanged.
  • Payloads missing those fields will now be rejected, as before e500757.

Generated by Claude Code

[SetsRequiredMembers] on the [JsonConstructor] ctors (added in e500757)
made System.Text.Json skip required-member checks, so a ServerCommit
without clientId or hybridDateTime deserialized with defaults. Fixes #104.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017iyZdteks1z5KpAsAAVMNt
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61c924d3-730c-40f9-b95c-0c0637062a4d
📥 Commits

Reviewing files that changed from the base of the PR and between 2398c3c and 132be78.

📒 Files selected for processing: 1
  • src/SIL.Harmony.Tests/Core/ServerCommitTests.cs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4aad868-e174-464f-b9bd-5a3fc73feeca
📥 Commits

Reviewing files that changed from the base of the PR and between c00599b and 2398c3c.

📒 Files selected for processing: 4
  • src/SIL.Harmony.Core/CommitBase.cs
  • src/SIL.Harmony.Core/ServerCommit.cs
  • src/SIL.Harmony.Tests/ServerCommitTests.cs
  • src/SIL.Harmony/Commit.cs
💤 Files with no reviewable changes: 3
  • src/SIL.Harmony.Core/ServerCommit.cs
  • src/SIL.Harmony/Commit.cs
  • src/SIL.Harmony.Core/CommitBase.cs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change removes SetsRequiredMembers annotations and unused imports from constructors in Commit, CommitBase, and ServerCommit. New tests check ServerCommit JSON round-tripping and verify that deserialization throws when clientId or hybridDateTime is missing.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: hahn-kev

Merge Risk: ⚪ Minimal · up to 2398c

Commit payloads missing clientId or hybridDateTime are rejected again, and tests now cover this. No outstanding issues block merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: enforcing required members during commit deserialization.
Description check Passed The description directly explains the removal of SetsRequiredMembers, the restored JSON validation, and the retained constructor behavior.
Linked Issues check Passed Issue #104 requires that deserializing a ServerCommit without clientId fails, as in rc.241. It also requires that a parameterless constructor not disable required-member enforcement. At the reviewed h…
Out of Scope Changes check Passed The changes stay within the regression fix for #104. ServerCommit.cs removes the [SetsRequiredMembers] attribute and its unused using directive. The diff for ServerCommit.cs at the reviewed head confi…
Full details: Linked Issues check

Explanation

Issue #104 requires that deserializing a ServerCommit without clientId fails, as in rc.241. It also requires that a parameterless constructor not disable required-member enforcement. At the reviewed head, the [JsonConstructor] constructor ServerCommit(Guid id, HybridDateTime hybridDateTime) no longer carries [SetsRequiredMembers]. The matching [JsonConstructor] constructor in CommitBase.cs also lacks it. ClientId (public required Guid ClientId { get; init; }) and HybridDateTime (public required HybridDateTime HybridDateTime { get; init; }) remain required in CommitBase. System.Text.Json skips required-member checks only when the selected constructor has [SetsRequiredMembers], so the required checks now apply again. The private parameterless ServerCommit() constructor has no [JsonConstructor] attribute and is not selected for deserialization. The public ServerCommit(Guid id) constructor is unchanged. The diff adds ServerCommitTests, which, per the change summary, asserts that removing clientId or hybridDateTime throws a JsonException naming the property. I did not execute the tests. The PASS rests on source inspection and the documented System.Text.Json behavior.

Full details: Out of Scope Changes check

Explanation

The changes stay within the regression fix for #104. ServerCommit.cs removes the [SetsRequiredMembers] attribute and its unused using directive. The diff for ServerCommit.cs at the reviewed head confirms this. CommitBase.cs removes the same attribute from its [JsonConstructor] constructors, which is the base-class path used by ServerCommit. Commit.cs (per the change summary) removes the same attribute from the protected Commit constructor. The PR description states that the attributes added in e500757 to the [JsonConstructor] constructors are removed. Commit.cs therefore applies the same restoration to a sibling type. ServerCommitTests.cs adds regression tests for this behavior, which supports the fix. The public constructors and the constructor bodies are unchanged. I found no unrelated changes in the reviewed summary.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017iyZdteks1z5KpAsAAVMNt
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.

ServerCommit no longer enforces required properties on JSON deserialization (regression rc.241 → rc.266)

2 participants