Skip to content

Fix import parameters#990

Open
etiennehomer wants to merge 3 commits into
mainfrom
fix_import_parameters
Open

Fix import parameters#990
etiennehomer wants to merge 3 commits into
mainfrom
fix_import_parameters

Conversation

@etiennehomer
Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR changes the importParameters type from Map<String, String> to Map<String, Object> across the study server. JSON serialization and deserialization helpers are added at the DTO-entity boundary to transparently convert between typed objects and string storage. Services and message consumers are updated to accept and propagate the new object-typed parameters.

Changes

Import Parameters Type Migration

Layer / File(s) Summary
DTO and Entity Serialization/Deserialization Infrastructure
src/main/java/org/gridsuite/study/server/dto/RootNetworkInfos.java, src/main/java/org/gridsuite/study/server/repository/rootnetwork/RootNetworkEntity.java
RootNetworkInfos.importParameters field is changed from Map<String, String> to Map<String, Object>. A serializeImportParameters() method is added to convert objects to JSON-serialized strings using Jackson before persistence. RootNetworkEntity adds a corresponding deserializeImportParameters() method to parse JSON strings back to objects when building DTOs, and toDto() applies this deserialization.
Service and Consumer Type Updates
src/main/java/org/gridsuite/study/server/service/ConsumerService.java, src/main/java/org/gridsuite/study/server/service/RootNetworkService.java, src/main/java/org/gridsuite/study/server/service/StudyService.java
ConsumerService removes string coercion and passes Map<String, Object> directly from message headers. RootNetworkService uses serializeImportParameters() when persisting updates and deserializeImportParameters() when retrieving, with getImportParameters() returning Map<String, Object>. StudyService updates insertStudy() and saveStudyThenCreateBasicTree() signatures to accept Map<String, Object>.
Test Compatibility
src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java
testCreateRootNetworkConsumer and its helper method createConsumeCaseImportSucceededHeaders() are updated to use Map<String, Object> for import parameters instead of Map<String, String>.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is empty with only a placeholder block provided, containing no meaningful information about the changes, objectives, or impact. Provide a detailed description explaining what the import parameters fix addresses, the before/after behavior, and any breaking changes or migration notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix import parameters' clearly and specifically describes the main change: updating how import parameters are handled across multiple service and DTO classes.
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.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

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: 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 `@src/main/java/org/gridsuite/study/server/service/RootNetworkService.java`:
- Line 187: The duplicated importParameters are being copied as
Map<String,Object> from a persisted Map<String,String> (newImportParameters =
Map.copyOf(rootNetworkEntityToDuplicate.getImportParameters())), which leads to
double-serialization when RootNetworkInfos.toEntity() writes them out; instead
transform the entries so String values that contain JSON are deserialized into
their native objects before storing in newImportParameters (e.g., iterate
rootNetworkEntityToDuplicate.getImportParameters(), for each entry: if value is
a String attempt to parse it with the project JSON mapper into Object, otherwise
keep as-is), then use that transformed map in place of the direct Map.copyOf to
prevent quoted strings becoming double-quoted JSON in
RootNetworkInfos.toEntity().
🪄 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: 0b5debd4-6097-4146-9ce5-258e59cd963f

📥 Commits

Reviewing files that changed from the base of the PR and between 7a04ef0 and 91d863f.

📒 Files selected for processing (6)
  • src/main/java/org/gridsuite/study/server/dto/RootNetworkInfos.java
  • src/main/java/org/gridsuite/study/server/repository/rootnetwork/RootNetworkEntity.java
  • src/main/java/org/gridsuite/study/server/service/ConsumerService.java
  • src/main/java/org/gridsuite/study/server/service/RootNetworkService.java
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
  • src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java


UUID clonedCaseUuid = caseService.duplicateCase(rootNetworkEntityToDuplicate.getCaseUuid(), false);
Map<String, String> newImportParameters = Map.copyOf(rootNetworkEntityToDuplicate.getImportParameters());
Map<String, Object> newImportParameters = Map.copyOf(rootNetworkEntityToDuplicate.getImportParameters());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid double-serializing duplicated import parameters.

Line 187 copies persisted Map<String, String> values directly into Map<String, Object>. Those values are then serialized again in RootNetworkInfos.toEntity(), which can corrupt payloads (e.g., quoted strings become double-quoted JSON strings).

💡 Suggested fix
-                Map<String, Object> newImportParameters = Map.copyOf(rootNetworkEntityToDuplicate.getImportParameters());
+                Map<String, Object> newImportParameters = RootNetworkEntity.deserializeImportParameters(rootNetworkEntityToDuplicate.getImportParameters());
🤖 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/study/server/service/RootNetworkService.java` at
line 187, The duplicated importParameters are being copied as Map<String,Object>
from a persisted Map<String,String> (newImportParameters =
Map.copyOf(rootNetworkEntityToDuplicate.getImportParameters())), which leads to
double-serialization when RootNetworkInfos.toEntity() writes them out; instead
transform the entries so String values that contain JSON are deserialized into
their native objects before storing in newImportParameters (e.g., iterate
rootNetworkEntityToDuplicate.getImportParameters(), for each entry: if value is
a String attempt to parse it with the project JSON mapper into Object, otherwise
keep as-is), then use that transformed map in place of the direct Map.copyOf to
prevent quoted strings becoming double-quoted JSON in
RootNetworkInfos.toEntity().

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