Skip to content

Add Check on network existence before fetching countries. - #4056

Open
basseche wants to merge 6 commits into
mainfrom
checkNetworkExists_BeforeCountriesFetch
Open

Add Check on network existence before fetching countries.#4056
basseche wants to merge 6 commits into
mainfrom
checkNetworkExists_BeforeCountriesFetch

Conversation

@basseche

Copy link
Copy Markdown
Contributor

PR Summary

Add a check to avoid snackbar error on countries fetch when root networks is invalidated.

Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
@basseche basseche self-assigned this Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f6b9a0c-3de8-4c46-8d8e-a431d4c78609

📥 Commits

Reviewing files that changed from the base of the PR and between cf0fbb5 and 2931eb0.

📒 Files selected for processing (1)
  • src/components/results/common/global-filter/hooks/use-global-filter-options.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The hook now loads country filters and substation properties through separate async helpers. It adds error handling for both flows. It also keeps the network existence check before the country fetch.

Changes

Global filter loading flow

Layer / File(s) Summary
Country loading with network guard
src/components/results/common/global-filter/hooks/use-global-filter-options.ts
Adds imports, keeps the study and node guard, checks network existence, fetches countries only for an OK response, and reports failures with snackWithFallback and FetchCountryError.
Substation property loading
src/components/results/common/global-filter/hooks/use-global-filter-options.ts
Extracts fetchSubstationProperties as a separate async helper, wraps the fetch and dispatch in try/catch, and invokes both helpers from the effect.

Sequence Diagram(s)

sequenceDiagram
  participant useGlobalFilterOptions
  participant fetchNetworkExistence
  participant fetchAllCountries
  participant snackWithFallback

  useGlobalFilterOptions->>fetchNetworkExistence: fetch network existence
  fetchNetworkExistence-->>useGlobalFilterOptions: response
  alt response.status is HttpStatusCode.OK
    useGlobalFilterOptions->>fetchAllCountries: fetch countries
    fetchAllCountries-->>useGlobalFilterOptions: country filters
  else request fails
    useGlobalFilterOptions->>snackWithFallback: FetchCountryError
  end
Loading

Suggested reviewers: klesaulnier

Merge Risk: ⚪ Minimal · up to 2931e

The change adds a guard before fetching countries and handles related fetch failures without introducing a broader product or production risk. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately states that the change adds a network-existence check to prevent a snackbar error when the root network is invalidated.
Title check ✅ Passed The title clearly identifies the main change: checking network existence before fetching countries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.


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.

@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

🤖 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/components/results/common/global-filter/use-global-filter-options.ts`:
- Around line 57-73: The fetchNetworkExistence promise chain is missing a
rejection handler, which can result in unhandled promise rejections if that call
fails. Add a .catch() handler to the fetchNetworkExistence(studyUuid,
currentRootNetworkUuid) promise chain to handle any errors that occur during the
network existence check, similar to how the fetchAllCountries call already has
error handling with snackWithFallback. This ensures all network requests in this
flow have proper error handling coverage.
🪄 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: 23abd83c-4522-45ea-9dc1-933ed71c036f

📥 Commits

Reviewing files that changed from the base of the PR and between 90b24e1 and 83c4e53.

📒 Files selected for processing (1)
  • src/components/results/common/global-filter/use-global-filter-options.ts

Comment thread src/components/results/common/global-filter/use-global-filter-options.ts Outdated
Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
@sonarqubecloud

Copy link
Copy Markdown

@etiennehomer etiennehomer reopened this Aug 5, 2026
…foreCountriesFetch

# Conflicts:
#	src/components/results/common/global-filter/hooks/use-global-filter-options.ts
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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

🤖 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/components/results/common/global-filter/hooks/use-global-filter-options.ts`:
- Line 58: Update the global-filter options flow so
fetchSubstationPropertiesGlobalFilters() runs independently using only the study
metadata. Keep the early return and network existence/country fetch gated by
studyUuid, currentNode?.id, and currentRootNetworkUuid, but invoke the
substation-property fetch before that context gate.
- Around line 57-77: Invoke the locally defined run function inside the
useEffect callback before the effect returns, ensuring the existing
network-existence check and country-fetch flow execute when its dependencies
change.
- Line 60: Update the request flow around fetchNetworkExistence in the run
callback to handle rejected transport promises before accessing response.status.
Attach the existing run rejection handler to cover this await, or catch the
fetchNetworkExistence failure locally and preserve the established error-state
behavior.
🪄 Autofix

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 Plus

Run ID: a3a47614-af0f-451b-bf34-7557e9e92e09

📥 Commits

Reviewing files that changed from the base of the PR and between 410fca8 and d3f80e0.

📒 Files selected for processing (1)
  • src/components/results/common/global-filter/hooks/use-global-filter-options.ts

Comment thread src/components/results/common/global-filter/hooks/use-global-filter-options.ts Outdated
Comment thread src/components/results/common/global-filter/hooks/use-global-filter-options.ts Outdated
Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
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.

2 participants