Skip to content

fix: keep temporary limits in REPLACE mode when nothing is applied#191

Open
flomillot wants to merge 1 commit into
mainfrom
fix/temporary-limits-replace-no-modification
Open

fix: keep temporary limits in REPLACE mode when nothing is applied#191
flomillot wants to merge 1 commit into
mainfrom
fix/temporary-limits-replace-no-modification

Conversation

@flomillot
Copy link
Copy Markdown
Contributor

Problem

In REPLACE mode, the existing temporary limits of a limit set were dropped unconditionally as soon as any limit was left untouched — 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

  • modifyTemporaryLimits now tracks whether at least one input actually applied a change (created / modified / deleted a temporary limit). In REPLACE mode the untouched limits are dropped only when at least one input was applied; otherwise the existing temporary limits are kept intact.
  • The "no match" check — a MODIFY input targeting a non-existing temporary limit — is extracted into isModifyWithoutMatch and moved before the duplicate check, so an ignored input has no side effect on the limit set.
  • temporaryLimitsNoMatch log message reworded for consistency with the other "ignored" messages.

Tests

testTemporaryLimitMissingFieldIsSkipped updated: an invalid input keeps the existing temporary limits for every modification type, REPLACE included.

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors temporary limit modifications to track whether actual changes occurred and validates MODIFY operations against existing limits. The applyTemporaryLimitModification() method now returns a boolean to enable change detection, supporting the new atLeastOneLimitApplied flag. A validation helper rejects unmatched MODIFY requests. Logging is consolidated and the detail log condition updated. Tests and user messages are aligned with the new behavior.

Changes

Temporary Limit Modification Tracking and Validation

Layer / File(s) Summary
Method signature and tracking initialization
src/main/java/org/gridsuite/modification/modifications/olg/OperationalLimitsGroupModification.java
applyTemporaryLimitModification() signature changed to return boolean to signal whether a modification was applied. The main modification loop initializes atLeastOneLimitApplied and updates it based on the method's return value.
Validation helper and control flow refactor
src/main/java/org/gridsuite/modification/modifications/olg/OperationalLimitsGroupModification.java
New isModifyWithoutMatch() helper validates that MODIFY operations target existing temporary limit durations; unmatched requests are logged as warnings and skipped. The applyTemporaryLimitModification() method refactored to use early boolean returns for pre-check failures, modify-without-match validation, duplicate detection, and successful create/modify/delete operations.
Logging consolidation and condition update
src/main/java/org/gridsuite/modification/modifications/olg/OperationalLimitsGroupModification.java
finalValueToReport computed earlier in modifyTemporaryLimit() and reused consistently across value-only and general modification log branches. The "temporaryLimitsReplaced" detail log condition now requires both areLimitsReplaced and atLeastOneLimitApplied to emit.
Message and test updates
src/main/resources/org/gridsuite/modification/reports.properties, src/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java
network.modification.temporaryLimitsNoMatch message updated with new formatting and "ignored" suffix. Test comments and assertions updated to remove REPLACE semantics; missing-field tests now expect existing temporary limits to remain unchanged regardless of modification type. Test warning message assertion aligned with new message format.

Suggested reviewers

  • Meklo
  • basseche
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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 directly describes the main fix: keeping temporary limits in REPLACE mode when no modifications are applied, which is the core change across all modified files.
Description check ✅ Passed The description comprehensively explains the problem, changes, and test updates related to temporary limits handling in REPLACE mode, which aligns with all modified files.
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.

✏️ 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.

❤️ Share

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

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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/modifications/tabularmodifications/LimitSetModificationsTest.java (1)

440-458: ⚡ Quick win

Add 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 the isModifyWithoutMatch + atLeastOneLimitApplied behavior.

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 286f4c9 and 801a07f.

📒 Files selected for processing (3)
  • src/main/java/org/gridsuite/modification/modifications/olg/OperationalLimitsGroupModification.java
  • src/main/resources/org/gridsuite/modification/reports.properties
  • src/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java

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