Skip to content

Migrate dangling lines import_parameters#1009

Open
etiennehomer wants to merge 4 commits into
mainfrom
migrate_import_parameters_from_cgmesDanglingLineBoundaryNode_to_cgmesBoundaryLineBoundaryNode
Open

Migrate dangling lines import_parameters#1009
etiennehomer wants to merge 4 commits into
mainfrom
migrate_import_parameters_from_cgmesDanglingLineBoundaryNode_to_cgmesBoundaryLineBoundaryNode

Conversation

@etiennehomer

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@etiennehomer, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b71d6256-26ab-435e-8a68-fc5d5578d2e2

📥 Commits

Reviewing files that changed from the base of the PR and between 7a19d46 and 375b394.

📒 Files selected for processing (1)
  • src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml
📝 Walkthrough

Walkthrough

This PR adds a database migration that renames two related parameter configurations in the import_parameters table: the extension value cgmesDanglingLineBoundaryNode becomes cgmesBoundaryLineBoundaryNode, and the import parameter key disconnect-dangling-line-if-boundary-side-is-disconnected becomes disconnect-boundary-line-if-boundary-side-is-disconnected. The migration is registered in the master Liquibase changelog.

Changes

Parameter key and value rename migration

Layer / File(s) Summary
Parameter rename migration and registration
src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml, src/main/resources/db/changelog/db.changelog-master.yaml
New Liquibase changeset with two SQL UPDATE statements that rename extension values and import parameter keys from "dangling-line" to "boundary-line" nomenclature in the import_parameters table, plus inclusion in the master changelog.

Suggested reviewers

  • AbdelHedhili
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: migrating dangling lines import_parameters to reflect the upstream renaming in powsybl-core.
Description check ✅ Passed The description is directly related to the changeset, explaining the context of the parameter migration following powsybl-core's dangling lines to boundary lines renaming.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 and usage tips.

Signed-off-by: Etienne Homer <[email protected]>
…LineBoundaryNode_to_cgmesBoundaryLineBoundaryNode

@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: 1

🧹 Nitpick comments (1)
src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml (1)

5-16: ⚡ Quick win

Consider 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

📥 Commits

Reviewing files that changed from the base of the PR and between 855200d and 7a19d46.

📒 Files selected for processing (2)
  • src/main/resources/db/changelog/changesets/changelog_20260612T125031Z.xml
  • src/main/resources/db/changelog/db.changelog-master.yaml

Comment on lines +7 to +10
UPDATE import_parameters
SET import_parameters = REPLACE(import_parameters, 'cgmesDanglingLineBoundaryNode', 'cgmesBoundaryLineBoundaryNode')
WHERE import_parameters_key = 'iidm.import.xml.included.extensions'
</sql>

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

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

Repository: 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.xml

Repository: 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 -S

Repository: 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.

@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