Skip to content

rename composite modification : update#812

Merged
souissimai merged 8 commits into
mainfrom
rename-composite-modification-update
May 13, 2026
Merged

rename composite modification : update#812
souissimai merged 8 commits into
mainfrom
rename-composite-modification-update

Conversation

@souissimai
Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
@coderabbitai

This comment was marked as low quality.

@Mathieu-Deharbe Mathieu-Deharbe self-requested a review May 6, 2026 11:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/gridsuite/network-modification-server/issues/comments/4377157091","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/gridsuite/network-modification-server/pull/812)\n<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->\n\n> [!NOTE]\n> Currently processing new changes in this PR. This may take a few minutes, please wait...\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: Organization UI\n> \n> **Review profile**: CHILL\n> \n> **Plan**: Pro\n> \n> **Run ID**: `3e035ad4-f58d-4f2a-8b3f-a9bf9cfd9753`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between f96564ca1038cd3860873282164e77e2ece456c2 and 8dec38e66998f64a711b29ae866e903c42918cc0.\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (1)</summary>\n> \n> * `src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`\n> \n> </details>\n> \n> \n\n<!-- end of auto-generated comment: review in progress by coderabbit.ai -->\n\n\n<!-- announcements_start -->\n\n> [!TIP]\n> <details>\n> <summary>💬 Introducing Slack Agent: The best way for teams to turn conversations into code.</summary>\n> \n> [Slack Agent](https://www.coderabbit.ai/agent) is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.\n> \n> - Generate code and open pull requests\n> - Plan features and break down work\n> - Investigate incidents and troubleshoot customer tickets together\n> - Automate recurring tasks and respond to alerts with triggers\n> - Summarize progress and report instantly\n> \n> Built for teams:\n> \n> - **Shared memory** across your entire org—no repeating context\n> - **Per-thread sandboxes** to safely plan and execute work\n> - **Governance built-in**—scoped access, auditability, and budget controls\n> \n> One agent for your entire SDLC. Right inside Slack.\n> \n> 👉 [Get started](https://agent.coderabbit.ai/)\n> \n> </details>\n\n<!-- announcements_end -->\n\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=gridsuite/network-modification-server&utm_content=812)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":3,"signal":{},"retries":3,"retryAfter":16}}}

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.

Actionable comments posted: 2

♻️ Duplicate comments (1)
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java (1)

739-739: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate that getMapMessageValues() is non-null before serialization.

Line 739 calls compositeMetadata.getMapMessageValues() without checking for null. If it returns null, Jackson's behavior depends on configuration, potentially causing NPEs or serializing the string "null" unexpectedly.

🛡️ Proposed fix: Add null check
     private void renameCompositeModifications(CompositeModificationEntity compositeEntity, CompositeModificationInfos compositeMetadata) {
         if (compositeMetadata.getName() != null) {
             compositeEntity.setName(compositeMetadata.getName());
-            compositeEntity.setMessageValues(new ObjectMapper().writeValueAsString(compositeMetadata.getMapMessageValues()));
+            Map<?, ?> messageValues = compositeMetadata.getMapMessageValues();
+            if (messageValues != null) {
+                compositeEntity.setMessageValues(objectMapper.writeValueAsString(messageValues));
+            }
         }
     }
🤖 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/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`
at line 739, The code calls compositeMetadata.getMapMessageValues() and
serializes it directly via new ObjectMapper().writeValueAsString(...), which can
yield unexpected "null" or cause NPEs; update the block around
compositeEntity.setMessageValues(...) to first check
compositeMetadata.getMapMessageValues() for null and only call
ObjectMapper().writeValueAsString when non-null, otherwise set
compositeEntity.setMessageValues(...) to a sensible default (e.g., null or "{}")
so serialization is deterministic; reference
compositeMetadata.getMapMessageValues(), ObjectMapper.writeValueAsString, and
compositeEntity.setMessageValues when making the change.
🤖 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
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Line 735: Remove the `@SneakyThrows` annotation on NetworkModificationRepository
and replace it with explicit handling around the Jackson serialization call that
currently relies on it (the code inside the `@Transactional` method around line
~710). Catch JsonProcessingException (or IOException) where
objectMapper.writeValueAsString / readValue is used, log a clear error via the
repository/class logger including the exception, and rethrow a suitable
unchecked exception (e.g., a custom RepositoryException or RuntimeException)
with a descriptive message so the transaction rollback is visible and
recoverable instead of being silently suppressed by `@SneakyThrows`.
- Line 739: The code creates a new ObjectMapper() for every call when setting
compositeEntity.setMessageValues(...), causing unnecessary allocations; add a
private final ObjectMapper field to the NetworkModificationRepository class,
initialize it via constructor injection (or a single shared instance created
once in the class) and replace the inline new ObjectMapper() usage in the method
that iterates (around the compositeEntity.setMessageValues call) with that field
to reuse the same thread-safe ObjectMapper instance.

---

Duplicate comments:
In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Line 739: The code calls compositeMetadata.getMapMessageValues() and
serializes it directly via new ObjectMapper().writeValueAsString(...), which can
yield unexpected "null" or cause NPEs; update the block around
compositeEntity.setMessageValues(...) to first check
compositeMetadata.getMapMessageValues() for null and only call
ObjectMapper().writeValueAsString when non-null, otherwise set
compositeEntity.setMessageValues(...) to a sensible default (e.g., null or "{}")
so serialization is deterministic; reference
compositeMetadata.getMapMessageValues(), ObjectMapper.writeValueAsString, and
compositeEntity.setMessageValues when making the change.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e035ad4-f58d-4f2a-8b3f-a9bf9cfd9753

📥 Commits

Reviewing files that changed from the base of the PR and between f96564c and 8dec38e.

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

Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
fix
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
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.

♻️ Duplicate comments (1)
src/main/java/org/gridsuite/modification/server/repositories/CompositeModificationRepository.java (1)

45-49: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid @SneakyThrows here and stop creating ObjectMapper per call.

At Line 45-49, this hides serialization failures and allocates a new mapper on every update. Handle the Jackson exception explicitly and reuse a single mapper instance.

🔧 Suggested patch
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.SneakyThrows;
 import org.gridsuite.modification.dto.CompositeModificationInfos;
 import org.gridsuite.modification.server.entities.CompositeModificationEntity;
@@
 public interface CompositeModificationRepository extends JpaRepository<CompositeModificationEntity, UUID> {
+    ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@@
-    `@SneakyThrows`
     default void renameCompositeModifications(CompositeModificationEntity compositeEntity, CompositeModificationInfos compositeMetadata) {
         compositeEntity.setName(compositeMetadata.getName());
-        compositeEntity.setMessageValues(new ObjectMapper().writeValueAsString(compositeMetadata.getMapMessageValues()));
+        try {
+            compositeEntity.setMessageValues(OBJECT_MAPPER.writeValueAsString(compositeMetadata.getMapMessageValues()));
+        } catch (JsonProcessingException e) {
+            throw new IllegalStateException("Failed to serialize composite messageValues for " + compositeEntity.getId(), e);
+        }
     }
 }
#!/bin/bash
# Verify occurrences in repository layer:
rg -n --type=java '@SneakyThrows|new ObjectMapper\(' src/main/java/org/gridsuite/modification/server/repositories
🤖 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/main/java/org/gridsuite/modification/server/repositories/CompositeModificationRepository.java`
around lines 45 - 49, Remove the use of `@SneakyThrows` on
renameCompositeModifications and stop instantiating new ObjectMapper each call:
add a shared ObjectMapper instance (e.g., a private static final ObjectMapper)
in the repository class and use it to serialize
compositeMetadata.getMapMessageValues(); catch and handle the Jackson checked
exception (JsonProcessingException) in renameCompositeModifications—either wrap
it in a specific runtime exception or handle/log appropriately—and update
CompositeModificationEntity.setMessageValues(...) only after successful
serialization; reference the method name renameCompositeModifications, the types
CompositeModificationEntity and CompositeModificationInfos, and the ObjectMapper
usage when making the change.
🤖 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.

Duplicate comments:
In
`@src/main/java/org/gridsuite/modification/server/repositories/CompositeModificationRepository.java`:
- Around line 45-49: Remove the use of `@SneakyThrows` on
renameCompositeModifications and stop instantiating new ObjectMapper each call:
add a shared ObjectMapper instance (e.g., a private static final ObjectMapper)
in the repository class and use it to serialize
compositeMetadata.getMapMessageValues(); catch and handle the Jackson checked
exception (JsonProcessingException) in renameCompositeModifications—either wrap
it in a specific runtime exception or handle/log appropriately—and update
CompositeModificationEntity.setMessageValues(...) only after successful
serialization; reference the method name renameCompositeModifications, the types
CompositeModificationEntity and CompositeModificationInfos, and the ObjectMapper
usage when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3a7ba662-6cc3-41f3-a111-d177dfb9c9ef

📥 Commits

Reviewing files that changed from the base of the PR and between 8dec38e and d1e5b0b.

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

@sonarqubecloud
Copy link
Copy Markdown

@souissimai souissimai merged commit 73809a3 into main May 13, 2026
5 checks passed
@souissimai souissimai deleted the rename-composite-modification-update branch May 13, 2026 11:17
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