add filter names in results#173
Conversation
📝 WalkthroughWalkthroughThis PR enhances the sensitivity analysis server to surface and use human-readable names for contingencies and filters in reports. A new service method aggregates available contingency lists and filter identifiers, a new controller endpoint exposes them, the input builder threads these names through all sensitivity construction paths to replace raw IDs in reports, and the REST API now accepts and passes the names map to the builder. ChangesSensitivity Analysis Naming Enhancement
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ 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. 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/sensitivityanalysis/server/SensitivityAnalysisController.java (1)
112-124:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
elementNamesMapis accepted but never propagated.At Line 112 the endpoint accepts the names map, but it is not used in Line 114-124. This makes the new contract ineffective and breaks the intended end-to-end name enrichment for
run-and-save.🧩 Suggested direction
- UUID resultUuid = service.runAndSaveResult(runContext); + UUID resultUuid = service.runAndSaveResult(runContext, elementNamesMap);(plus corresponding signature propagation in downstream service/context layers)
🤖 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/sensitivityanalysis/server/SensitivityAnalysisController.java` around lines 112 - 124, The endpoint accepts elementNamesMap but never forwards it into the run context; update SensitivityAnalysisController to pass elementNamesMap into sensitivityAnalysisParametersService.createRunContext (and then into SensitivityAnalysisRunContext), and propagate that new field through any downstream methods (e.g., SensitivityAnalysisParametersService.createRunContext, SensitivityAnalysisRunContext constructor/fields and service.runAndSaveResult) by adding the parameter to their signatures and using it when building the context so the name enrichment flows end-to-end.
🧹 Nitpick comments (2)
src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java (1)
286-286: ⚡ Quick winRemove temporary/debug comments before merge.
Line 286 and Line 313 contain temporary/debug notes that should not stay in production code.
Also applies to: 313-313
🤖 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/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java` at line 286, Remove the temporary/debug comments left in the SensitivityAnalysisInputBuilderService source (the French notes about "vérifier ce qu'il y a dans les varaibleSets" and the other debug note around the same area) before merging; locate them inside the SensitivityAnalysisInputBuilderService class (the method building or validating input sets) and delete those inline comments or replace them with a concise, production-ready TODO or proper Javadoc if a follow-up task is required.src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java (1)
165-197: ⚡ Quick winDeduplicate aggregated UUIDs before returning.
The current aggregation can return duplicates, which adds avoidable payload and redundant downstream name-resolution calls.
♻️ Suggested change
- List<UUID> contingencyListsAndFiltersUuids = new ArrayList<>(); + Set<UUID> contingencyListsAndFiltersUuids = new LinkedHashSet<>(); ... - return contingencyListsAndFiltersUuids; + return new ArrayList<>(contingencyListsAndFiltersUuids);🤖 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/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java` around lines 165 - 197, The aggregated UUID list contingencyListsAndFiltersUuids in SensitivityAnalysisParametersService can contain duplicates; change the aggregation to deduplicate before returning by either collecting into a LinkedHashSet (to preserve insertion order) instead of an ArrayList or by converting the List to a stream and applying distinct() (e.g., contingencyListsAndFiltersUuids.stream().distinct().collect(...)); ensure the returned collection remains a List<UUID> if callers expect it (convert the Set back to a List) and keep references to the same variables: contingencyListsAndFiltersUuids and the parameter sources like getSensitivityInjectionsSet(), getSensitivityInjection(), getSensitivityHVDC(), getSensitivityPST(), getSensitivityNodes().
🤖 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/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`:
- Around line 162-164: The method getContingencyListsAndFiltersParameters in
SensitivityAnalysisParametersService currently throws IllegalArgumentException
when no parameters are found; change this to throw a
SensitivityAnalysisException with the appropriate business code (e.g.,
FILTERS_OR_CONTINGENCIES_LISTS_NOT_FOUND or a new NOT_FOUND code) and a
descriptive message so the existing SensitivityAnalysisExceptionHandler maps it
to a 404; locate the empty-check for parameters in
SensitivityAnalysisParametersService and replace the IllegalArgumentException
with a SensitivityAnalysisException instance carrying the correct business code
and message.
---
Outside diff comments:
In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.java`:
- Around line 112-124: The endpoint accepts elementNamesMap but never forwards
it into the run context; update SensitivityAnalysisController to pass
elementNamesMap into sensitivityAnalysisParametersService.createRunContext (and
then into SensitivityAnalysisRunContext), and propagate that new field through
any downstream methods (e.g.,
SensitivityAnalysisParametersService.createRunContext,
SensitivityAnalysisRunContext constructor/fields and service.runAndSaveResult)
by adding the parameter to their signatures and using it when building the
context so the name enrichment flows end-to-end.
---
Nitpick comments:
In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.java`:
- Line 286: Remove the temporary/debug comments left in the
SensitivityAnalysisInputBuilderService source (the French notes about "vérifier
ce qu'il y a dans les varaibleSets" and the other debug note around the same
area) before merging; locate them inside the
SensitivityAnalysisInputBuilderService class (the method building or validating
input sets) and delete those inline comments or replace them with a concise,
production-ready TODO or proper Javadoc if a follow-up task is required.
In
`@src/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`:
- Around line 165-197: The aggregated UUID list contingencyListsAndFiltersUuids
in SensitivityAnalysisParametersService can contain duplicates; change the
aggregation to deduplicate before returning by either collecting into a
LinkedHashSet (to preserve insertion order) instead of an ArrayList or by
converting the List to a stream and applying distinct() (e.g.,
contingencyListsAndFiltersUuids.stream().distinct().collect(...)); ensure the
returned collection remains a List<UUID> if callers expect it (convert the Set
back to a List) and keep references to the same variables:
contingencyListsAndFiltersUuids and the parameter sources like
getSensitivityInjectionsSet(), getSensitivityInjection(), getSensitivityHVDC(),
getSensitivityPST(), getSensitivityNodes().
🪄 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: dff692d3-0c13-41c3-8ddc-cd78d7587149
📒 Files selected for processing (4)
src/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisController.javasrc/main/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisParametersController.javasrc/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisInputBuilderService.javasrc/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java
| if (parameters.isEmpty()) { | ||
| throw new IllegalArgumentException("No parameters found for parametersUuid: " + parametersUuid); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether IllegalArgumentException is mapped to HTTP 404 in this codebase
rg -n --type=java "(`@ControllerAdvice`|`@ExceptionHandler`|IllegalArgumentException|HttpStatus\.NOT_FOUND|ResponseStatusException)"Repository: gridsuite/sensitivity-analysis-server
Length of output: 2014
Throw a semantic “not found” exception for missing parametersUuid instead of IllegalArgumentException.
SensitivityAnalysisParametersService#getContingencyListsAndFiltersParameters throws IllegalArgumentException when parameters is empty (line 163). SensitivityAnalysisExceptionHandler is the only @ControllerAdvice hit and it maps only SensitivityAnalysisException business codes (including FILTERS_OR_CONTINGENCIES_LISTS_NOT_FOUND → 404); there is no handler mapping IllegalArgumentException to HTTP 404. Use SensitivityAnalysisException (or a dedicated not-found code) for missing parametersUuid to align with the endpoint’s 404 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/main/java/org/gridsuite/sensitivityanalysis/server/service/SensitivityAnalysisParametersService.java`
around lines 162 - 164, The method getContingencyListsAndFiltersParameters in
SensitivityAnalysisParametersService currently throws IllegalArgumentException
when no parameters are found; change this to throw a
SensitivityAnalysisException with the appropriate business code (e.g.,
FILTERS_OR_CONTINGENCIES_LISTS_NOT_FOUND or a new NOT_FOUND code) and a
descriptive message so the existing SensitivityAnalysisExceptionHandler maps it
to a 404; locate the empty-check for parameters in
SensitivityAnalysisParametersService and replace the IllegalArgumentException
with a SensitivityAnalysisException instance carrying the correct business code
and message.
PR Summary