Fix import parameters#990
Conversation
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
📝 WalkthroughWalkthroughThis PR changes the ChangesImport Parameters Type Migration
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
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
📒 Files selected for processing (6)
src/main/java/org/gridsuite/study/server/dto/RootNetworkInfos.javasrc/main/java/org/gridsuite/study/server/repository/rootnetwork/RootNetworkEntity.javasrc/main/java/org/gridsuite/study/server/service/ConsumerService.javasrc/main/java/org/gridsuite/study/server/service/RootNetworkService.javasrc/main/java/org/gridsuite/study/server/service/StudyService.javasrc/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()); |
There was a problem hiding this comment.
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().
PR Summary