transmit CompositesToBeInserted to network modifications server#1004
transmit CompositesToBeInserted to network modifications server#1004Mathieu-Deharbe wants to merge 4 commits into
Conversation
Signed-off-by: Mathieu DEHARBE <[email protected]>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis pull request generalizes the composite modifications insertion payload contract from a strictly-typed ChangesComposite Modifications Payload Generalization
Suggested Reviewers
🚥 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🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/org/gridsuite/study/server/service/StudyService.java (1)
2337-2346:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftReplace
List<Object>with a typed/validated payload contract for composite network modifications.
StudyService.insertCompositeNetworkModifications(...)now takescompositesInfosasList<Object>and forwards it unchanged intoNetworkModificationService.insertCompositeModifications(...)asPair<List<Object>, List<ModificationApplicationContext>>, which then sends it to the network-modification-server. This removes the study-server boundary schema/type guarantees, so malformed JSON array elements will only surface downstream at runtime rather than being rejected/validated early (e.g.,StudyService.java:2337-2346,NetworkModificationService.java:285-296).
Define explicit DTO(s (or useJsonNodewith per-shape validation) for the supported composite item structures before forwarding.🤖 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/StudyService.java` around lines 2337 - 2346, StudyService.insertCompositeNetworkModifications currently accepts compositesInfos as List<Object] and forwards it to NetworkModificationService.insertCompositeModifications, losing type guarantees; replace the raw List<Object> with a typed DTO (or JsonNode with validation) representing the allowed composite item shapes, update the method signature and call sites (StudyService.insertCompositeNetworkModifications, duplicateModificationsOrInsertComposites invocation, and NetworkModificationService.insertCompositeModifications) to use List<YourCompositeDto> (or List<JsonNode> plus explicit per-item validation), add validation logic to reject/transform malformed items before constructing the Pair passed to networkModificationService, and adjust any downstream handling to consume the new DTO type.
🧹 Nitpick comments (1)
src/main/java/org/gridsuite/study/server/controller/StudyController.java (1)
693-695: ⚡ Quick winMake the request-body schema explicit in docs despite using
List<Object>.The Javadoc mentions
List<CompositesToBeInserted>, but the actual method signature isList<Object>. Add explicit OpenAPI schema/examples for this endpoint so client contract remains clear and codegen/documentation do not degrade into “array of any”.🤖 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/controller/StudyController.java` around lines 693 - 695, The endpoint currently takes List<Object> (parameter compositesToBeInserted) which yields an "array of any" in docs; annotate the controller method in StudyController to provide an explicit OpenAPI request-body schema by adding `@io.swagger.v3.oas.annotations.parameters.RequestBody` on the method (or parameter) and supply Content with mediaType "application/json" and an ArraySchema whose schema points to a concrete documentation-only type (e.g. CompositesToBeInsertedDoc) or an inline `@Schema` describing expected properties; if no runtime DTO exists create a small static inner class CompositesToBeInsertedDoc with the fields used by network-modification-server and reference it via `@ArraySchema`(schema=`@Schema`(implementation=CompositesToBeInsertedDoc.class)) and add an `@ExampleObject` to show a sample payload so codegen/docs produce a clear contract despite the handler using List<Object>.
🤖 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/controller/StudyController.java`:
- Around line 699-715: The controller currently accepts List<Object>
compositesToBeInserted and forwards it to
handleInsertCompositeNetworkModifications without structural checks; add a
strict payload-shape validation step (either in insertCompositeModifications
before calling handleInsertCompositeNetworkModifications or at the top of
handleInsertCompositeNetworkModifications before calling
studyService.invalidateNodeTreeWithLF) that iterates compositesToBeInserted and
verifies each element matches the expected shape/type (e.g., Pair or Map with
required keys/types and any enum values), and if any element is invalid
immediately throw a 4xx (ResponseStatusException with BAD_REQUEST) so invalid
requests fail fast and prevent node-tree invalidation; reference the parameter
compositesToBeInserted, the controller method insertCompositeModifications, and
the helper handleInsertCompositeNetworkModifications when adding this guard.
---
Outside diff comments:
In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Around line 2337-2346: StudyService.insertCompositeNetworkModifications
currently accepts compositesInfos as List<Object] and forwards it to
NetworkModificationService.insertCompositeModifications, losing type guarantees;
replace the raw List<Object> with a typed DTO (or JsonNode with validation)
representing the allowed composite item shapes, update the method signature and
call sites (StudyService.insertCompositeNetworkModifications,
duplicateModificationsOrInsertComposites invocation, and
NetworkModificationService.insertCompositeModifications) to use
List<YourCompositeDto> (or List<JsonNode> plus explicit per-item validation),
add validation logic to reject/transform malformed items before constructing the
Pair passed to networkModificationService, and adjust any downstream handling to
consume the new DTO type.
---
Nitpick comments:
In `@src/main/java/org/gridsuite/study/server/controller/StudyController.java`:
- Around line 693-695: The endpoint currently takes List<Object> (parameter
compositesToBeInserted) which yields an "array of any" in docs; annotate the
controller method in StudyController to provide an explicit OpenAPI request-body
schema by adding `@io.swagger.v3.oas.annotations.parameters.RequestBody` on the
method (or parameter) and supply Content with mediaType "application/json" and
an ArraySchema whose schema points to a concrete documentation-only type (e.g.
CompositesToBeInsertedDoc) or an inline `@Schema` describing expected properties;
if no runtime DTO exists create a small static inner class
CompositesToBeInsertedDoc with the fields used by network-modification-server
and reference it via
`@ArraySchema`(schema=`@Schema`(implementation=CompositesToBeInsertedDoc.class)) and
add an `@ExampleObject` to show a sample payload so codegen/docs produce a clear
contract despite the handler using List<Object>.
🪄 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: 486782b0-1382-4c22-9d7f-3f2d0c6c0474
📒 Files selected for processing (3)
src/main/java/org/gridsuite/study/server/controller/StudyController.javasrc/main/java/org/gridsuite/study/server/service/NetworkModificationService.javasrc/main/java/org/gridsuite/study/server/service/StudyService.java
Signed-off-by: Mathieu DEHARBE <[email protected]>
Signed-off-by: Mathieu DEHARBE <[email protected]>
PR Summary