fix: keep temporary limits in REPLACE mode when nothing is applied#191
fix: keep temporary limits in REPLACE mode when nothing is applied#191flomillot wants to merge 5 commits into
Conversation
In REPLACE mode the existing temporary limits were dropped unconditionally as soon as any limit was left untouched, even when every provided input was rejected by validation (missing field, duplicate name, no match). The limit set was emptied although no modification had actually been performed. The existing temporary limits are now kept untouched unless at least one input actually created, modified or deleted a temporary limit. The "no match" check (a MODIFY input targeting a non-existing temporary limit) is also moved before the duplicate check, so an ignored input has no side effect on the limit set. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors temporary-limit processing to track whether inputs applied changes, adds validation to skip MODIFY rows with no matching duration, splits missing/duplicate report keys into name vs duration variants, changes applyTemporaryLimitModification to return boolean, and updates tests and messages to match the new behavior. ChangesTemporary Limit Modification Tracking and Validation
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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)
src/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java (1)
440-458: ⚡ Quick winAdd an explicit REPLACE + no-match regression case.
This now covers missing-field rejection in REPLACE mode, but not the
MODIFY-without-match rejection path that was also part of the bug scenario. Adding that case here would better lock theisModifyWithoutMatch+atLeastOneLimitAppliedbehavior.🤖 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/modifications/tabularmodifications/LimitSetModificationsTest.java` around lines 440 - 458, The test currently checks missing-field rejection for one path but lacks a regression case for a MODIFY-without-match scenario; update the MethodSource "missingTemporaryLimitFieldCases" (the provider used by testTemporaryLimitMissingFieldIsSkipped) to include an explicit case where TemporaryLimitModificationType is MODIFY and the modification targets a non-matching limit (simulate "no-match"), so the code exercises the isModifyWithoutMatch + atLeastOneLimitApplied logic; ensure the new case still results in no changes to existing temporary limits (assertEquals(2, limits.getTemporaryLimits().size()) remains valid) and reuse the existing buildMissingFieldModification/ModificationInfos setup so the test asserts the missing-field rejection path for MODIFY-without-match.
🤖 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/modifications/tabularmodifications/LimitSetModificationsTest.java`:
- Around line 440-458: The test currently checks missing-field rejection for one
path but lacks a regression case for a MODIFY-without-match scenario; update the
MethodSource "missingTemporaryLimitFieldCases" (the provider used by
testTemporaryLimitMissingFieldIsSkipped) to include an explicit case where
TemporaryLimitModificationType is MODIFY and the modification targets a
non-matching limit (simulate "no-match"), so the code exercises the
isModifyWithoutMatch + atLeastOneLimitApplied logic; ensure the new case still
results in no changes to existing temporary limits (assertEquals(2,
limits.getTemporaryLimits().size()) remains valid) and reuse the existing
buildMissingFieldModification/ModificationInfos setup so the test asserts the
missing-field rejection path for MODIFY-without-match.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 130d6292-3b57-4a45-ae91-64f1355c7319
📒 Files selected for processing (3)
src/main/java/org/gridsuite/modification/modifications/olg/OperationalLimitsGroupModification.javasrc/main/resources/org/gridsuite/modification/reports.propertiessrc/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java
Missing-info and duplicate-conflict checks each emitted a single log covering both fields. Split into per-field templates (temporaryLimitsMissingName / temporaryLimitsMissingDuration, temporaryLimitsDuplicateName / temporaryLimitsDuplicateDuration) and aggregate the validity result so every problem on a row is reported. Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Remove unnecessary value change check to ensure logs are emitted only when the name is modified, avoiding redundant log entries. Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Simplified condition to ensure logging occurs only when the name is modified, improving clarity and avoiding redundant code. Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…cationCheck - `handleUnmodifiedTemporaryLimits` factored out of `modifyTemporaryLimits`. - `preModificationCheck` split into `checkTemporaryLimitModificationType` (per-limit modificationType consistency) and `checkTemporaryLimitMandatoryFields` (presence of name and duration); both are always evaluated so every problem on a limit is reported. Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
|



Problem
In REPLACE mode, the existing temporary limits of a limit set were dropped unconditionally, even when every provided input had been rejected by validation (missing name/duration, duplicate name, no match). The limit set ended up empty although no modification had actually been performed.
Changes
modifyTemporaryLimitsnow tracks whether at least one input actually applied a change. In REPLACE mode the untouched limits are dropped only when at least one input was applied; otherwise the existing temporary limits are kept intact.MODIFYinput targeting a non-existing temporary limit — is extracted intoisModifyWithoutMatchand moved before the duplicate check.temporaryLimitsNoMatchlog message reworded for consistency with the other "ignored" messages.temporaryLimitsMissingInfobecomestemporaryLimitsMissingName/temporaryLimitsMissingDuration, andtemporaryLimitsDuplicatebecomestemporaryLimitsDuplicateName/temporaryLimitsDuplicateDuration.preModificationCheckandwouldCreateDuplicatenow aggregate problems instead of returning on the first one, so a row that fails several checks reports every individual issue.handleUnmodifiedTemporaryLimits, andpreModificationCheckis split intocheckTemporaryLimitModificationType(modificationType consistency) andcheckTemporaryLimitMandatoryFields(presence of name and duration).