Skip to content

keep only filter ids in back for sc parameters#1185

Draft
EtienneLt wants to merge 11 commits into
mainfrom
check-filter-from-shortcircuit-server-2
Draft

keep only filter ids in back for sc parameters#1185
EtienneLt wants to merge 11 commits into
mainfrom
check-filter-from-shortcircuit-server-2

Conversation

@EtienneLt

Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt self-assigned this Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9725da2-12df-4663-ad2a-38ee54f0c7d4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Types and utils now serialize short-circuit cluster filters as raw UUID arrays; service-layer enrichment resolves those UUIDs into {id,name} objects via fetchElementNames and returns enriched parameters. Small debug logs added in form reset and parameter update.

Changes

Filter ID enrichment and serialization

Layer / File(s) Summary
PowerElectronicsCluster type update
src/features/parameters/short-circuit/short-circuit-parameters.type.ts
PowerElectronicsCluster.filters type changes from FilterIdentifier[] to UUID[]; FilterIdentifier import removed.
Parameter serialization and formatting
src/features/parameters/short-circuit/short-circuit-parameters-utils.ts
Import change and helper relocation; getShortCircuitSpecificParametersValues now serializes power-electronics cluster filters and node-cluster filter IDs as ID-only JSON arrays. Formatting/parsing logic updated to parse provider JSON as {id,name} and remap into {[ID],[NAME]} formatted values.
Service-layer parameter enrichment
src/services/short-circuit-analysis.ts
Add study-scoped URL helper and parsing helpers; implement enrichShortCircuitParameters() to collect referenced IDs, call fetchElementNames(), and rewrite provider-specific JSON fields into arrays of {id,name}; integrate enrichment into fetchShortCircuitParameters() and add getShortCircuitParameters(studyUuid); add debug log in update path.
Form initialization debug
src/features/parameters/short-circuit/use-short-circuit-parameters-form.ts
Insert console.log('reset', params) in the form reset effect.

Suggested reviewers:

  • sBouzols
  • thangqp
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is empty and contains only a template header with no substantive information about the changes, motivation, or implementation details. Provide a meaningful description explaining the rationale for switching to ID-only filter storage, the impact on data serialization, and any breaking changes or migration considerations.
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 accurately reflects the main change: refactoring short-circuit parameters to store and serialize only filter IDs instead of full filter objects.
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.


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.

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/features/parameters/short-circuit/short-circuit-parameters-utils.ts`:
- Around line 247-250: The mapper powerElectronicsClustersParam currently
spreads rest and thus persists the form-only active flag; update the mapping in
the block that handles powerElectronicsClustersParam so you destructure and omit
active (e.g., const { filters, active, ...rest } = sParam) and return { ...rest,
filters: lightFilters } so active is not written to
specificParametersPerProvider; then ensure the form-enrichment path (where you
build FormPowerElectronicsCluster for the UI) re-adds active: true when
converting stored PowerElectronicsCluster back to the form model.

In `@src/services/short-circuit-analysis.ts`:
- Around line 35-43: The JSON.parse calls in parseNodeClusters (and the sibling
parsePowerElectronicsClusters used in lines ~46-57) can throw and abort
parameter loading; wrap each JSON.parse(...) in a try/catch and on parse failure
treat the provider-local value as an empty array/set instead of throwing—i.e.,
if parsing succeeds convert the result to the expected Set<string> and set it
into filterIdsFromNodeCluster, otherwise set an empty Set for that provider
(optionally log the parse error), so a single malformed persisted JSON value
doesn't break
enrichShortCircuitParameters()/fetchShortCircuitParameters()/getShortCircuitParameters().
🪄 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: 11924157-f0cc-47fd-bb81-e83b66bb496c

📥 Commits

Reviewing files that changed from the base of the PR and between b46e381 and 506c036.

📒 Files selected for processing (3)
  • src/features/parameters/short-circuit/short-circuit-parameters-utils.ts
  • src/features/parameters/short-circuit/short-circuit-parameters.type.ts
  • src/services/short-circuit-analysis.ts

Comment on lines +35 to +43
function parseNodeClusters(parameters: ShortCircuitParametersInfos): Map<string, Set<string>> {
const filterIdsFromNodeCluster = new Map<string, Set<string>>();
Object.entries(parameters.specificParametersPerProvider).forEach(([provider, specificParamValue]) => {
if (Object.hasOwn(specificParamValue, NODE_CLUSTER_FILTER_IDS)) {
const filters = JSON.parse(specificParamValue[NODE_CLUSTER_FILTER_IDS]);
filterIdsFromNodeCluster.set(provider, filters);
}
});
return filterIdsFromNodeCluster;

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

Malformed persisted JSON now breaks parameter loading.

Both parsing helpers call JSON.parse(...) on stored provider values with no fallback. One bad nodeClusterFilterIds or powerElectronicsClusters string will reject enrichShortCircuitParameters(), which now means both fetchShortCircuitParameters() and getShortCircuitParameters() fail before the form can reset. Treat parse failures as provider-local fallbacks ([]) instead of aborting the whole fetch.

Also applies to: 46-57

🤖 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/services/short-circuit-analysis.ts` around lines 35 - 43, The JSON.parse
calls in parseNodeClusters (and the sibling parsePowerElectronicsClusters used
in lines ~46-57) can throw and abort parameter loading; wrap each
JSON.parse(...) in a try/catch and on parse failure treat the provider-local
value as an empty array/set instead of throwing—i.e., if parsing succeeds
convert the result to the expected Set<string> and set it into
filterIdsFromNodeCluster, otherwise set an empty Set for that provider
(optionally log the parse error), so a single malformed persisted JSON value
doesn't break
enrichShortCircuitParameters()/fetchShortCircuitParameters()/getShortCircuitParameters().

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/features/parameters/short-circuit/short-circuit-parameters-utils.ts (1)

290-307: 💤 Low value

Unused defaultValues parameter.

The defaultValues parameter is never referenced in the function body—only specificParamValue is parsed and mapped. If clusters intentionally have no default-merging logic (unlike materials), remove the unused parameter to avoid confusion.

Also, per static analysis: delete the extra blank line at line 307.

♻️ Proposed fix
-const formatElectronicsClustersParamString = (
-    defaultValues: PowerElectronicsCluster[],
-    specificParamValue: string,
-    snackError: (message: SnackInputs) => void
-) => {
+const formatElectronicsClustersParamString = (
+    specificParamValue: string,
+    snackError: (message: SnackInputs) => void
+) => {

And update the call site at line 348-354:

             formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = formatElectronicsClustersParamString(
-                getDefaultShortCircuitSpecificParamsValues([powerElectronicsClustersParam], snackError)?.[
-                    SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS
-                ],
                 specificParamsList[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] as string,
                 snackError
             );
🤖 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/features/parameters/short-circuit/short-circuit-parameters-utils.ts`
around lines 290 - 307, Remove the unused defaultValues parameter from
formatElectronicsClustersParamString and update its signature to only accept
(specificParamValue: string, snackError: (message: SnackInputs) => void); inside
the function keep the call to parsePowerElectronicsClustersParamString and the
mapping logic unchanged (referenced symbols:
formatElectronicsClustersParamString, parsePowerElectronicsClustersParamString,
snackError); then update all call sites that still pass a defaultValues argument
to call the new two-argument signature and remove the extra blank line at the
end of the file.

Source: Linters/SAST tools

🤖 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/features/parameters/short-circuit/short-circuit-parameters-utils.ts`:
- Around line 276-288: The parser parsePowerElectronicsClustersParamString
currently claims to return (PowerElectronicsCluster & { active: boolean })[] but
actually receives enriched filters with objects {id, name}; create a new
EnrichedPowerElectronicsCluster type (e.g., type EnrichedPowerElectronicsCluster
= PowerElectronicsCluster & { filters: {id: UUID; name: string}[]; active:
boolean }) and change parsePowerElectronicsClustersParamString's return type to
EnrichedPowerElectronicsCluster[]; update any callers (notably
formatElectronicsClustersParamString) to accept/handle
EnrichedPowerElectronicsCluster so accessing filter.id and filter.name is
type-safe; ensure JSON.parse is cast to EnrichedPowerElectronicsCluster[] and
keep the same error handling, and remove the extra blank line preceding the
function declaration.
- Around line 364-369: The JSON.parse call for NODE_CLUSTER_FILTER_IDS lacks
error handling and can throw on malformed backend data; wrap the parsing in a
try-catch similar to
parsePowerElectronicsMaterialsParamString/parsePowerElectronicsClustersParamString,
catch the error, call snackWithFallback with an appropriate user-facing message,
and set formatted[NODE_CLUSTER_FILTER_IDS] to an empty array or safe default;
keep the mapping that uses ID and NAME keys from filter.id/filter.name and read
from specificParamsList[NODE_CLUSTER_FILTER_IDS] inside the try block so
failures don't crash the parameter loading flow.

In `@src/features/parameters/short-circuit/use-short-circuit-parameters-form.ts`:
- Line 296: Remove the debug console.log that prints the entire parameters
payload in the reset path: delete or replace the line console.log('reset',
params) in use-short-circuit-parameters-form.ts (the reset handling block that
references params) so production consoles do not receive full study
configuration; if logging is required, log a minimal, non-sensitive message or a
sanitized/summary value instead.

---

Nitpick comments:
In `@src/features/parameters/short-circuit/short-circuit-parameters-utils.ts`:
- Around line 290-307: Remove the unused defaultValues parameter from
formatElectronicsClustersParamString and update its signature to only accept
(specificParamValue: string, snackError: (message: SnackInputs) => void); inside
the function keep the call to parsePowerElectronicsClustersParamString and the
mapping logic unchanged (referenced symbols:
formatElectronicsClustersParamString, parsePowerElectronicsClustersParamString,
snackError); then update all call sites that still pass a defaultValues argument
to call the new two-argument signature and remove the extra blank line at the
end of the file.
🪄 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: ab5e0f71-2d0a-46c6-ad2f-a8a7de16b74b

📥 Commits

Reviewing files that changed from the base of the PR and between 506c036 and 0219f9b.

📒 Files selected for processing (3)
  • src/features/parameters/short-circuit/short-circuit-parameters-utils.ts
  • src/features/parameters/short-circuit/use-short-circuit-parameters-form.ts
  • src/services/short-circuit-analysis.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/short-circuit-analysis.ts

Comment thread src/features/parameters/short-circuit/short-circuit-parameters-utils.ts Outdated
Comment on lines +364 to 369
// NODE_CLUSTER_FILTER_IDS is parsed when getting shortcircuit parameters
const filters = JSON.parse(specificParamsList[NODE_CLUSTER_FILTER_IDS]);
formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { filterId: any; filterName: any }) => ({
[ID]: filter.filterId,
[NAME]: filter.filterName, // from back to front -> {id: uuid, name: string}
formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { id: any; name: any }) => ({
[ID]: filter.id,
[NAME]: filter.name, // from back to front -> {id: uuid, name: string}
}));

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

Missing error handling for JSON.parse on node-cluster filter IDs.

Unlike parsePowerElectronicsMaterialsParamString and parsePowerElectronicsClustersParamString, this JSON.parse call has no try-catch. If the backend returns malformed JSON in NODE_CLUSTER_FILTER_IDS, the formatter will throw and crash the parameter loading flow.

Wrap in try-catch with snackWithFallback for consistency:

🐛 Proposed fix
         if (Object.hasOwn(specificParamsList, NODE_CLUSTER_FILTER_IDS)) {
-            // NODE_CLUSTER_FILTER_IDS is parsed when getting shortcircuit parameters
-            const filters = JSON.parse(specificParamsList[NODE_CLUSTER_FILTER_IDS]);
-            formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { id: any; name: any }) => ({
-                [ID]: filter.id,
-                [NAME]: filter.name, // from back to front -> {id: uuid, name: string}
-            }));
+            // NODE_CLUSTER_FILTER_IDS is parsed when getting shortcircuit parameters
+            try {
+                const filters = JSON.parse(specificParamsList[NODE_CLUSTER_FILTER_IDS]);
+                formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { id: any; name: any }) => ({
+                    [ID]: filter.id,
+                    [NAME]: filter.name,
+                }));
+            } catch (error) {
+                snackWithFallback(snackError, error, { headerId: 'ShortCircuitNodeClusterFilterIdsParsingError' });
+                formatted[NODE_CLUSTER_FILTER_IDS] = [];
+            }
         } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// NODE_CLUSTER_FILTER_IDS is parsed when getting shortcircuit parameters
const filters = JSON.parse(specificParamsList[NODE_CLUSTER_FILTER_IDS]);
formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { filterId: any; filterName: any }) => ({
[ID]: filter.filterId,
[NAME]: filter.filterName, // from back to front -> {id: uuid, name: string}
formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { id: any; name: any }) => ({
[ID]: filter.id,
[NAME]: filter.name, // from back to front -> {id: uuid, name: string}
}));
// NODE_CLUSTER_FILTER_IDS is parsed when getting shortcircuit parameters
try {
const filters = JSON.parse(specificParamsList[NODE_CLUSTER_FILTER_IDS]);
formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter: { id: any; name: any }) => ({
[ID]: filter.id,
[NAME]: filter.name,
}));
} catch (error) {
snackWithFallback(snackError, error, { headerId: 'ShortCircuitNodeClusterFilterIdsParsingError' });
formatted[NODE_CLUSTER_FILTER_IDS] = [];
}
🤖 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/features/parameters/short-circuit/short-circuit-parameters-utils.ts`
around lines 364 - 369, The JSON.parse call for NODE_CLUSTER_FILTER_IDS lacks
error handling and can throw on malformed backend data; wrap the parsing in a
try-catch similar to
parsePowerElectronicsMaterialsParamString/parsePowerElectronicsClustersParamString,
catch the error, call snackWithFallback with an appropriate user-facing message,
and set formatted[NODE_CLUSTER_FILTER_IDS] to an empty array or safe default;
keep the mapping that uses ID and NAME keys from filter.id/filter.name and read
from specificParamsList[NODE_CLUSTER_FILTER_IDS] inside the try block so
failures don't crash the parameter loading flow.

if (!params || !provider || !specificParamsDescription) {
return;
}
console.log('reset', params);

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 | 🟡 Minor | ⚡ Quick win

Remove debug logging of full parameter payload in reset path.

console.log('reset', params) emits the entire parameters object on a routine UI path and can leak study configuration details in production consoles while adding noise.

Suggested fix
-        console.log('reset', params);
         reset(toShortCircuitFormValues(params));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('reset', params);
reset(toShortCircuitFormValues(params));
🤖 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/features/parameters/short-circuit/use-short-circuit-parameters-form.ts`
at line 296, Remove the debug console.log that prints the entire parameters
payload in the reset path: delete or replace the line console.log('reset',
params) in use-short-circuit-parameters-form.ts (the reset handling block that
references params) so production consoles do not receive full study
configuration; if logging is required, log a minimal, non-sensitive message or a
sanitized/summary value instead.

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/features/parameters/short-circuit/short-circuit-parameters-utils.ts (2)

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

active flag still serialized for clusters (unlike materials).

Line 242 correctly strips active from materials: const { active, ...rest } = sParam. However, line 248 only destructures filters, leaving active in ...rest which gets serialized to the backend. This persists UI-only state in the stored parameters.

🐛 Proposed fix
         finalSpecificParameters[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = JSON.stringify(
             powerElectronicsClustersParam.map((sParam) => {
-                const { filters, ...rest } = sParam;
+                const { filters, active, ...rest } = sParam;
                 const lightFilters = filters?.map((filter) => filter[ID]) ?? [];
                 return { ...rest, filters: lightFilters };
             })
         );
🤖 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/features/parameters/short-circuit/short-circuit-parameters-utils.ts`
around lines 246 - 252, The serialized clusters still include the UI-only active
flag because the mapping only strips filters; update the mapping for
powerElectronicsClustersParam used to set
finalSpecificParameters[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] to also
destructure and remove active (e.g., const { active, filters, ...rest } =
sParam) before building the returned object so only the intended fields (with
filters reduced to ids) are serialized to the backend.

276-287: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Build failure: type mismatch between declared return type and actual runtime data.

parsePowerElectronicsClustersParamString declares its return type as (PowerElectronicsCluster & { active: boolean })[], where filters is UUID[]. However, at line 300, formatElectronicsClustersParamString maps each filter as { id: string; name: string } — the enriched shape returned by the service layer after enrichShortCircuitParameters resolves IDs to {id, name} objects.

Define an enriched type that reflects the actual runtime shape after service-layer enrichment:

🐛 Proposed fix

In short-circuit-parameters.type.ts, add:

export interface EnrichedPowerElectronicsCluster extends BasePowerElectronicsCluster {
    filters: FilterPOJO[];
}

Then in this file:

 const parsePowerElectronicsClustersParamString = (
     paramString: string,
     snackError: (message: SnackInputs) => void
-): (PowerElectronicsCluster & { active: boolean })[] => {
+): (EnrichedPowerElectronicsCluster & { active: boolean })[] => {
     // Attempt to parse the string into an array of PowerElectronicsCluster objects
     try {
         return JSON.parse(paramString);

And update formatElectronicsClustersParamString:

 const formatElectronicsClustersParamString = (
-    defaultValues: PowerElectronicsCluster[],
+    defaultValues: EnrichedPowerElectronicsCluster[],
     specificParamValue: string,
     snackError: (message: SnackInputs) => void
 ) => {
-    const electronicsClustersArrayInParams: (PowerElectronicsCluster & { active: boolean })[] =
+    const electronicsClustersArrayInParams: (EnrichedPowerElectronicsCluster & { active: boolean })[] =
         parsePowerElectronicsClustersParamString(specificParamValue, snackError);
     return electronicsClustersArrayInParams.map((cluster) => {
         const { filters, ...rest } = cluster;
         return {
             ...rest,
-            filters: filters.map((filter: { id: string; name: string }) => ({
+            filters: filters.map((filter) => ({
                 [ID]: filter.id,
                 [NAME]: filter.name,
             })),

Also applies to: 300-303

🤖 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/features/parameters/short-circuit/short-circuit-parameters-utils.ts`
around lines 276 - 287, The runtime shape returned by the service is enriched
(filters are objects like {id,name}) so create a new type
EnrichedPowerElectronicsCluster (e.g. export interface
EnrichedPowerElectronicsCluster extends BasePowerElectronicsCluster { filters:
FilterPOJO[] }) in short-circuit-parameters.type.ts, then update
parsePowerElectronicsClustersParamString to return
EnrichedPowerElectronicsCluster[] instead of (PowerElectronicsCluster & {
active: boolean })[] and update formatElectronicsClustersParamString to
map/expect filters as FilterPOJO ({id:string,name:string}) accordingly; ensure
references to BasePowerElectronicsCluster, FilterPOJO,
parsePowerElectronicsClustersParamString, and
formatElectronicsClustersParamString are updated to use the new
EnrichedPowerElectronicsCluster type.

Source: Linters/SAST tools

🤖 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.

Outside diff comments:
In `@src/features/parameters/short-circuit/short-circuit-parameters-utils.ts`:
- Around line 246-252: The serialized clusters still include the UI-only active
flag because the mapping only strips filters; update the mapping for
powerElectronicsClustersParam used to set
finalSpecificParameters[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] to also
destructure and remove active (e.g., const { active, filters, ...rest } =
sParam) before building the returned object so only the intended fields (with
filters reduced to ids) are serialized to the backend.
- Around line 276-287: The runtime shape returned by the service is enriched
(filters are objects like {id,name}) so create a new type
EnrichedPowerElectronicsCluster (e.g. export interface
EnrichedPowerElectronicsCluster extends BasePowerElectronicsCluster { filters:
FilterPOJO[] }) in short-circuit-parameters.type.ts, then update
parsePowerElectronicsClustersParamString to return
EnrichedPowerElectronicsCluster[] instead of (PowerElectronicsCluster & {
active: boolean })[] and update formatElectronicsClustersParamString to
map/expect filters as FilterPOJO ({id:string,name:string}) accordingly; ensure
references to BasePowerElectronicsCluster, FilterPOJO,
parsePowerElectronicsClustersParamString, and
formatElectronicsClustersParamString are updated to use the new
EnrichedPowerElectronicsCluster type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7ab19e8-0a32-47a9-9f7a-3c2546fffde6

📥 Commits

Reviewing files that changed from the base of the PR and between 0219f9b and a3ed601.

📒 Files selected for processing (3)
  • src/features/parameters/short-circuit/short-circuit-parameters-utils.ts
  • src/features/parameters/short-circuit/short-circuit-parameters.type.ts
  • src/services/short-circuit-analysis.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/short-circuit-analysis.ts

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