Skip to content

Clean orphans when updating composite modifications#843

Merged
Meklo merged 4 commits into
mainfrom
marcellinh/clean_orphans_updating_composite_modification
Jul 8, 2026
Merged

Clean orphans when updating composite modifications#843
Meklo merged 4 commits into
mainfrom
marcellinh/clean_orphans_updating_composite_modification

Conversation

@Meklo

@Meklo Meklo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

PR Summary

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Meklo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3cfdb115-66f4-4c75-beb9-8e6fbc6d43ff

📥 Commits

Reviewing files that changed from the base of the PR and between b1143cd and 4d1bf12.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
  • src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
📝 Walkthrough

Walkthrough

The repository's updateCompositeModification method now deletes a composite's previously held child modifications before reassigning the new ordered modification list. CompositeControllerTest is updated to use a dedicated networkModificationRepository for most stored-data queries while using modificationRepository specifically to verify deletion of stale child modifications.

Changes

Composite update deletion fix and test verification

Layer / File(s) Summary
Delete prior child modifications
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
updateCompositeModification now calls deleteModifications(...) on the composite's existing modifications before persisting the new reordered clone list.
Repository field wiring in tests
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
Adds a ModificationRepository import and splits fields into networkModificationRepository (NetworkModificationRepository) and modificationRepository (ModificationRepository); @AfterEach cleanup now uses networkModificationRepository.
Update verification calls across composite tests
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
Migrates stored-data assertions (getModificationInfo, getModifications, getModificationEntity) across testSplit, testInsert, createSomeSwitchModifications, testDuplicateCompositeModification, testMoveSubModificationFromCompositeToRoot, testAssembleNetworkModificationsIntoNewComposite, testMoveSubModificationFromRootToComposite, and testCreateCompositeFromSingleCompositeDoesNotWrap to use networkModificationRepository.
Verify deletion of prior composite children
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
In testUpdateNetworkCompositeModification, captures pre-update child UUIDs and asserts via modificationRepository.findAllByIdIn(...).size() == 0 that they were deleted, alongside group-modification verification via networkModificationRepository.

Suggested reviewers: Mathieu-Deharbe, souissimai

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is just a template prompt and does not actually summarize the changes. Replace the template text with a brief summary of what changed, why, and any reviewer notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately states the main change: cleaning orphaned child modifications during composite updates.
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.

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

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java (1)

334-346: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Good regression test for the orphan-cleanup fix.

Capturing the composite's actual cloned child UUIDs before update and asserting their deletion via modificationRepository.findAllByIdIn(...) correctly targets the fix in NetworkModificationRepository.updateCompositeModification.

This only covers flat/leaf sub-modifications though. Given the nested-composite orphan gap flagged in NetworkModificationRepository.java (Lines 183-186), consider adding a variant where one of the composite's children is itself a nested composite, and assert its descendants are also deleted after the update.

🤖 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 `@src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java`
around lines 334 - 346, Add a regression test that covers the nested-composite
orphan cleanup gap in addition to the existing flat child case. In
CompositeControllerTest, reuse the composite update flow around
get(URI_GET_COMPOSITE_NETWORK_MODIF_CONTENT) and
put(URI_COMPOSITE_NETWORK_MODIF_BASE, ...) but build a child structure where one
child is itself a composite, then capture both the nested composite UUID and its
descendant UUIDs before the update. After calling the update, assert via
modificationRepository.findAllByIdIn(...) that the nested child and its
descendants are all deleted, so the test exercises the behavior fixed in
NetworkModificationRepository.updateCompositeModification.
🤖 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
`@src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java`:
- Around line 334-346: Add a regression test that covers the nested-composite
orphan cleanup gap in addition to the existing flat child case. In
CompositeControllerTest, reuse the composite update flow around
get(URI_GET_COMPOSITE_NETWORK_MODIF_CONTENT) and
put(URI_COMPOSITE_NETWORK_MODIF_BASE, ...) but build a child structure where one
child is itself a composite, then capture both the nested composite UUID and its
descendant UUIDs before the update. After calling the update, assert via
modificationRepository.findAllByIdIn(...) that the nested child and its
descendants are all deleted, so the test exercises the behavior fixed in
NetworkModificationRepository.updateCompositeModification.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8357d15a-7348-4b0d-98a1-28cc8a761552

📥 Commits

Reviewing files that changed from the base of the PR and between 3bffb36 and b1143cd.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
  • src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java

@Meklo Meklo requested a review from Mathieu-Deharbe July 7, 2026 08:24

@Mathieu-Deharbe Mathieu-Deharbe 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.

Code OK, test OK.

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@Meklo Meklo merged commit e1e62e2 into main Jul 8, 2026
4 checks passed
@Meklo Meklo deleted the marcellinh/clean_orphans_updating_composite_modification branch July 8, 2026 14:35
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.

2 participants