Skip to content

Robustify node building / unbuilding#976

Open
basseche wants to merge 3 commits intomainfrom
robustify_node_build
Open

Robustify node building / unbuilding#976
basseche wants to merge 3 commits intomainfrom
robustify_node_build

Conversation

@basseche
Copy link
Copy Markdown
Contributor

@basseche basseche commented Apr 9, 2026

PR Summary

Robustify node building :

@basseche basseche self-assigned this Apr 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99b90862-c6dc-4a15-9e81-acbf504e11b8

📥 Commits

Reviewing files that changed from the base of the PR and between 60aef47 and 371f61a.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/study/server/controller/StudyController.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/gridsuite/study/server/controller/StudyController.java

📝 Walkthrough

Walkthrough

Added an eligibility pre-check in the StudyController unbuild endpoint and narrowed exception handling in ConsumerService so only JSON parsing errors are caught during build-result processing.

Changes

Cohort / File(s) Summary
Unbuild eligibility check
src/main/java/org/gridsuite/study/server/controller/StudyController.java
Inserted studyService.assertCanBuildNode(rootNetworkUuid, nodeUuid) into unbuildNode() after the existing blocked-node check and before studyService.unbuildStudyNode(...), preventing unbuild unless the node is eligible.
Exception handling refinement
src/main/java/org/gridsuite/study/server/service/ConsumerService.java
Replaced a broad catch (Exception ...) with catch (JsonProcessingException ...) in consumeBuildResult(), so only JSON parsing errors are intercepted during build-success handling.
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
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.
Description check ❓ Inconclusive The description is incomplete and provides minimal information, containing only 'Robustify node building :' with no details about the actual changes or implementation. Complete the description by explaining the specific changes: the authorization pre-check added to unbuildNode and the exception handling refinement in ConsumerService.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Robustify node building / unbuilding' directly describes the main changes: adding a pre-check for node build eligibility in unbuildNode and refining exception handling in buildResult processing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
src/main/java/org/gridsuite/study/server/controller/StudyController.java

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/org/gridsuite/study/server/controller/StudyController.java`:
- Line 1678: The current call
rootNetworkNodeInfoService.assertNoBuildingNode(rootNetworkUuid,
List.of(nodeUuid)) only checks the single target node; change it to collect all
UUIDs for the whole branch/path that could be affected (e.g. via the service
that resolves branch nodes — for example getBranchNodeUuids(rootNetworkUuid,
nodeUuid) or traverse parents/children) and pass that full list into
rootNetworkNodeInfoService.assertNoBuildingNode; update the code around the call
in StudyController (method handling the unbuild operation) to compute
relatedBranchUuids and call assertNoBuildingNode(rootNetworkUuid,
relatedBranchUuids) so concurrent BUILDING states on any branch node are
guarded.

In `@src/main/java/org/gridsuite/study/server/service/ConsumerService.java`:
- Around line 133-135: handleBuildSuccess(...) is currently invoked before
handleBuildResultWorkflow(...) and only JsonProcessingException is caught, so
runtime errors from workflow metadata parsing (e.g., WorkflowType.valueOf) can
crash the consumer after the build side-effects have been applied; wrap the call
to handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(),
receiverObj.getRootNetworkUuid(), message) in its own try/catch (catch broad
RuntimeException or IllegalArgumentException/IllegalStateException as
appropriate) so parsing or workflow-specific errors are logged/handled without
propagating and without undoing the successful path performed by
studyService.handleBuildSuccess(...).
🪄 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: fcb67c53-9d5a-4f4d-9761-276dd18b55c9

📥 Commits

Reviewing files that changed from the base of the PR and between bbbfed2 and 08349c2.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/study/server/controller/StudyController.java
  • src/main/java/org/gridsuite/study/server/service/ConsumerService.java

Comment thread src/main/java/org/gridsuite/study/server/controller/StudyController.java Outdated
Comment on lines 133 to +135
studyService.handleBuildSuccess(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), networkModificationResult);
handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), message);
} catch (Exception e) {
} catch (JsonProcessingException e) {
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

Isolate workflow-header failures from the successful build path.

At Line 133, handleBuildSuccess(...) commits side effects before workflow handling. With Line 135 now catching only JsonProcessingException, runtime failures from workflow metadata parsing (e.g., WorkflowType.valueOf) can bubble up and fail the consumer after success was already applied.

💡 Proposed fix
                     UUID studyUuid = networkModificationTreeService.getStudyUuidForNodeId(receiverObj.getNodeUuid());
                     studyService.handleBuildSuccess(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), networkModificationResult);
-                    handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), message);
+                    try {
+                        handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), message);
+                    } catch (JsonProcessingException | IllegalArgumentException e) {
+                        LOGGER.warn("Ignoring malformed workflow metadata for node '{}'", receiverObj.getNodeUuid(), e);
+                    }
                 } catch (JsonProcessingException e) {
                     LOGGER.error(e.toString());
                 }
📝 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
studyService.handleBuildSuccess(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), networkModificationResult);
handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), message);
} catch (Exception e) {
} catch (JsonProcessingException e) {
studyService.handleBuildSuccess(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), networkModificationResult);
try {
handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(), receiverObj.getRootNetworkUuid(), message);
} catch (JsonProcessingException | IllegalArgumentException e) {
LOGGER.warn("Ignoring malformed workflow metadata for node '{}'", receiverObj.getNodeUuid(), e);
}
} catch (JsonProcessingException e) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/gridsuite/study/server/service/ConsumerService.java` around
lines 133 - 135, handleBuildSuccess(...) is currently invoked before
handleBuildResultWorkflow(...) and only JsonProcessingException is caught, so
runtime errors from workflow metadata parsing (e.g., WorkflowType.valueOf) can
crash the consumer after the build side-effects have been applied; wrap the call
to handleBuildResultWorkflow(studyUuid, receiverObj.getNodeUuid(),
receiverObj.getRootNetworkUuid(), message) in its own try/catch (catch broad
RuntimeException or IllegalArgumentException/IllegalStateException as
appropriate) so parsing or workflow-specific errors are logged/handled without
propagating and without undoing the successful path performed by
studyService.handleBuildSuccess(...).

Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
@sonarqubecloud
Copy link
Copy Markdown

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