Skip to content

Tolerate complex form parent already deleted during FwData sync#2374

Merged
myieye merged 2 commits into
developfrom
debug-thai-sync-error
Jun 24, 2026
Merged

Tolerate complex form parent already deleted during FwData sync#2374
myieye merged 2 commits into
developfrom
debug-thai-sync-error

Conversation

@myieye

@myieye myieye commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Resolves #2373

Just ran into this when trying to sync the rmunn thai-food project in prod.

This bug/exception could also be fixed by re-reading all the FwData entries before diffing/syncing complex forms and components. I.e. make the diff reflect any cascaded deletes before moving to a new phase.

Funny that we just dealt with this sort of thing in CRDT-land. But this is different, here in fwdata-land.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: be6a991c-61a6-4dd1-b275-29f159fb4c7f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

DeleteComplexFormComponent in FwDataMiniLcmApi is updated to use TryGetObject instead of GetObject, returning early if the parent complex form entry no longer exists. A new regression test verifies that EntrySync.SyncFull completes without throwing when the complex form parent has been deleted before the sync diffing phase runs.

Changes

Fix and test DeleteComplexFormComponent missing parent crash

Layer / File(s) Summary
Guard and regression test
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs, backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs
DeleteComplexFormComponent now calls TryGetObject and returns immediately when the complex form parent entry is absent, preventing a KeyNotFoundException. A new [Fact] test (SyncFull_RemovingComplexFormWhoseParentWasDeleted_DoesNotThrow) creates a component, deletes the parent, clears ComplexForms on the surviving component, runs SyncFull, and asserts the component still exists.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • hahn-kev

Poem

🐇 A form was deleted, the parent was gone,
But GetObject still tried to carry on.
Now TryGetObject peeks with care,
Returns early if nobody's there.
No more crashes, the sync hops along! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: tolerating a deleted complex form parent during FwData sync.
Description check ✅ Passed The description is directly related to the sync crash and proposed fix described in the changeset.
Linked Issues check ✅ Passed The code and regression test implement the requested guard for a missing complex form parent in #2373.
Out of Scope Changes check ✅ Passed The PR appears focused on the sync fix and its regression test, with no obvious unrelated changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch debug-thai-sync-error

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.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jun 23, 2026
@argos-ci

argos-ci Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jun 24, 2026, 9:06 AM

Comment thread backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs Outdated

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

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 `@backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs`:
- Line 1092: `DeleteComplexFormComponent` has an invalid early-exit for a
`Task`-returning method: replace the bare guard return after
`EntriesRepository.TryGetObject(...)` with a completed task return so the
method’s return type stays consistent. Update the guard in
`FwDataMiniLcmApi.DeleteComplexFormComponent` to return `Task.CompletedTask`
when the entry lookup fails, and keep the rest of the method unchanged.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e4510edf-54f7-4299-9028-dc5617ddd835

📥 Commits

Reviewing files that changed from the base of the PR and between ff6ac34 and 6916faf.

📒 Files selected for processing (2)
  • backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
  • backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs

Comment thread backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs Outdated
@myieye myieye force-pushed the debug-thai-sync-error branch from 6916faf to 9d24b43 Compare June 24, 2026 09:03
@myieye myieye merged commit 7bd2a81 into develop Jun 24, 2026
20 checks passed
@myieye myieye deleted the debug-thai-sync-error branch June 24, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting a complex form in CRDT crashes the FwData sync

2 participants