Migrate dangling lines import_parameters#1009
Conversation
…BoundaryLineBoundaryNode Signed-off-by: Etienne Homer <[email protected]>
…sconnected Signed-off-by: Etienne Homer <[email protected]>
|
Warning Review limit reached
More reviews will be available in 55 minutes and 25 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a database migration that renames two related parameter configurations in the ChangesParameter key and value rename migration
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Signed-off-by: Etienne Homer <[email protected]>
…LineBoundaryNode_to_cgmesBoundaryLineBoundaryNode
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml (1)
5-16: ⚡ Quick winConsider adding rollback logic to the changeset.
This changeset modifies existing data but doesn't define rollback behavior. If the migration needs to be rolled back, manual intervention would be required.
Consider adding rollback SQL statements that reverse both updates:
<rollback> <sql> UPDATE import_parameters SET import_parameters = REPLACE(import_parameters, 'cgmesBoundaryLineBoundaryNode', 'cgmesDanglingLineBoundaryNode') WHERE import_parameters_key = 'iidm.import.xml.included.extensions' </sql> <sql> UPDATE import_parameters SET import_parameters_key = 'iidm.import.cgmes.disconnect-dangling-line-if-boundary-side-is-disconnected' WHERE import_parameters_key = 'iidm.import.cgmes.disconnect-boundary-line-if-boundary-side-is-disconnected' </sql> </rollback>🤖 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/resources/db/changelog/changesets/changelog_20260612T125031Z.xml` around lines 5 - 16, Add a rollback block to the changeSet id "1781261546000-1" that reverses both UPDATEs on the import_parameters table: replace the string change in the import_parameters column back from 'cgmesBoundaryLineBoundaryNode' to 'cgmesDanglingLineBoundaryNode' for the same import_parameters_key, and rename the import_parameters_key back from 'iidm.import.cgmes.disconnect-boundary-line-if-boundary-side-is-disconnected' to 'iidm.import.cgmes.disconnect-dangling-line-if-boundary-side-is-disconnected'; include these as two SQL statements inside a <rollback> element so Liquibase can automatically undo the data changes if needed.
🤖 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/resources/db/changelog/changesets/changelog_20260612T125031Z.xml`:
- Around line 7-10: The UPDATE uses a raw REPLACE that can mangle JSON; change
the REPLACE to target the exact JSON string (e.g., include surrounding quotes so
you replace '"cgmesDanglingLineBoundaryNode"' with
'"cgmesBoundaryLineBoundaryNode"') or use a JSON-aware update so the JSON
structure stays valid (see JsonUtils.deserializeImportParameters /
ImportParametersMigration for expected format), and add explicit <rollback>
sections for changeSet id="1781261546000-1" and id="1781261978000-1" that undo
the string substitution (replace '"cgmesBoundaryLineBoundaryNode"' back to
'"cgmesDanglingLineBoundaryNode"') and revert any import_parameters_key renames
so the DB can be returned to its prior state.
---
Nitpick comments:
In `@src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml`:
- Around line 5-16: Add a rollback block to the changeSet id "1781261546000-1"
that reverses both UPDATEs on the import_parameters table: replace the string
change in the import_parameters column back from 'cgmesBoundaryLineBoundaryNode'
to 'cgmesDanglingLineBoundaryNode' for the same import_parameters_key, and
rename the import_parameters_key back from
'iidm.import.cgmes.disconnect-boundary-line-if-boundary-side-is-disconnected' to
'iidm.import.cgmes.disconnect-dangling-line-if-boundary-side-is-disconnected';
include these as two SQL statements inside a <rollback> element so Liquibase can
automatically undo the data changes if needed.
🪄 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: 2cb49a36-a70d-4307-b8c0-dafe08b724c8
📒 Files selected for processing (2)
src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xmlsrc/main/resources/db/changelog/db.changelog-master.yaml
| UPDATE import_parameters | ||
| SET import_parameters = REPLACE(import_parameters, 'cgmesDanglingLineBoundaryNode', 'cgmesBoundaryLineBoundaryNode') | ||
| WHERE import_parameters_key = 'iidm.import.xml.included.extensions' | ||
| </sql> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check the structure and content of import_parameters to verify REPLACE safety
# Search for any database query/schema files that show the import_parameters table structure
rg -n "import_parameters" --type=sql -C 3
# Look for examples of import_parameters values in test files or documentation
rg -n "iidm\.import\.xml\.included\.extensions" -A 5 -B 2Repository: gridsuite/study-server
Length of output: 1661
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Find DDL/schema definitions mentioning the import_parameters column type
rg -n "import_parameters(_key)?\b|CREATE TABLE.*import_parameters|ALTER TABLE.*import_parameters" \
--hidden -S -g'*.sql' -g'*.ddl' -g'*.java' -g'*.kt' -g'*.groovy' -g'*.xml' -g'*.yml' -g'*.yaml' .
# 2) Search for JSON functions/usages around import_parameters (if supported by the DB)
rg -n "import_parameters\b.*(json|cast|->>|->|JSON_|to_json|jsonb|replace\()" -S .
rg -n "(json|jsonb)\b.*import_parameters\b" -S .
# 3) Look for other REPLACE updates on import_parameters to gauge precedent/risk
rg -n "REPLACE\s*\(\s*import_parameters\s*," -S src/main/resources/db/changelog/changesets .
# 4) Inspect related changeset/script content to see if import_parameters is treated as structured data
sed -n '1,120p' src/main/resources/db/changelog/changesets/migrationImportParamsToRootNetwork.sql
sed -n '1,200p' src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xmlRepository: gridsuite/study-server
Length of output: 6056
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Inspect the datatype change to CLOB
rg -n "modifyDataType.*import_parameters" src/main/resources/db/changelog/changesets/changelog_20230906T074248Z.xml
sed -n '1,120p' src/main/resources/db/changelog/changesets/changelog_20230906T074248Z.xml
# 2) Inspect how import_parameters table was created
sed -n '1,120p' src/main/resources/db/changelog/changesets/changelog_20230711T111525Z.xml
sed -n '1,120p' src/main/resources/db/changelog/changesets/changelog_20230711T084649Z.xml
# 3) Inspect the migration code that reads/writes import_parameters
sed -n '1,220p' src/main/java/org/gridsuite/study/server/migration/ImportParametersMigration.java
# 4) Search for JSON parsing/usage around import_parameters in Java
rg -n "import_parameters\b|import_parameters_key\b" src/main/java/org/gridsuite/study/server -S
rg -n "(ObjectMapper|Jackson|Json|parse|JSONObject|JSONArray|readValue)" src/main/java/org/gridsuite/study/server -SRepository: gridsuite/study-server
Length of output: 50378
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml"
# 1) Show the whole relevant changeset(s) around the snippet (first ~80 lines)
sed -n '1,120p' "$FILE"
# 2) Find all occurrences of the old/new extension strings in the repo
rg -n "cgmesDanglingLineBoundaryNode" -S .
rg -n "cgmesBoundaryLineBoundaryNode" -S .
# 3) Inspect JsonUtils handling for import_parameters (deserialize/serialize)
JSONUTILS="src/main/java/org/gridsuite/study/server/utils/JsonUtils.java"
sed -n '60,140p' "$JSONUTILS"
sed -n '140,240p' "$JSONUTILS"
# 4) Inspect how RootNetworkEntity stores importParameters (serialization path)
ROOTENTITY="src/main/java/org/gridsuite/study/server/repository/rootnetwork/RootNetworkEntity.java"
sed -n '60,130p' "$ROOTENTITY"Repository: gridsuite/study-server
Length of output: 6104
Make the REPLACE update precise (and add rollback) for import_parameters
import_parameters values are expected to contain JSON (they’re deserialized/serialized via Jackson in JsonUtils.deserializeImportParameters / serializeImportParameters, and normalized by ImportParametersMigration). Replacing cgmesDanglingLineBoundaryNode with cgmesBoundaryLineBoundaryNode should therefore not break JSON syntax.
However, this is still a raw string substitution: it can modify unintended partial occurrences. Scope the replacement to exact JSON string matches (e.g., include surrounding quotes in the REPLACE arguments) or use JSON-aware SQL updates if available.
Also, changelog_20260612T125031Z.xml changeSet id="1781261546000-1" and id="1781261978000-1" contain no <rollback> logic—add rollback to revert both the value substitution and the import_parameters_key rename.
🤖 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/resources/db/changelog/changesets/changelog_20260612T125031Z.xml`
around lines 7 - 10, The UPDATE uses a raw REPLACE that can mangle JSON; change
the REPLACE to target the exact JSON string (e.g., include surrounding quotes so
you replace '"cgmesDanglingLineBoundaryNode"' with
'"cgmesBoundaryLineBoundaryNode"') or use a JSON-aware update so the JSON
structure stays valid (see JsonUtils.deserializeImportParameters /
ImportParametersMigration for expected format), and add explicit <rollback>
sections for changeSet id="1781261546000-1" and id="1781261978000-1" that undo
the string substitution (replace '"cgmesBoundaryLineBoundaryNode"' back to
'"cgmesDanglingLineBoundaryNode"') and revert any import_parameters_key renames
so the DB can be returned to its prior state.
|



PR Summary
After dangling lines renaming to boundary lines (powsybl/powsybl-core#3624), saved imports parameters should be renamed.
This is a gridsuite side solution that forces gridsuite to well manage when import parameters and extensions change.
A more robust solution might be implemented by powsybl to ensure backward compatibility.