Capture notification to fetch new path when study is renamed in gridExplroe#4093
Capture notification to fetch new path when study is renamed in gridExplroe#4093basseche wants to merge 2 commits into
Conversation
…xplore Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe directory server types now expose directory metadata and its header key. ChangesDirectory path refresh
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
license-eye has totally checked 816 files.
| Valid | Invalid | Ignored | Fixed |
|---|---|---|---|
| 767 | 1 | 48 | 0 |
Click to see the invalid file list
- src/types/directory-server-types.ts
Signed-off-by: basseche <bassel.el-cheikh_externe@rte-france.com>
There was a problem hiding this comment.
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/hooks/use-study-path.ts`:
- Around line 71-72: In the WebSocket message handler, guard access to the
DIRECTORIES_INFOS header before parsing and wrap JSON.parse in a try/catch to
handle absent or malformed values without escaping the callback. Update the
directory-processing logic in the onMessage callback to continue safely when
parsing fails, while preserving the existing
studyParentDirectoriesUuidsRef.current matching behavior.
🪄 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: 7c8fccc1-1d7e-457d-a84d-4eb85485466b
📒 Files selected for processing (2)
src/hooks/use-study-path.tssrc/types/directory-server-types.ts
| const directoryInfos: DirectoryInfos[] = JSON.parse(eventData.headers[DIRECTORIES_INFOS]); | ||
| if (directoryInfos.some((info) => studyParentDirectoriesUuidsRef.current.includes(info.uuid))) { |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Guard against missing or malformed DIRECTORIES_INFOS header.
JSON.parse(eventData.headers[DIRECTORIES_INFOS]) will throw a SyntaxError if the header is absent (undefined) or contains invalid JSON. This runs inside a WebSocket onMessage callback — an uncaught exception here could silently break the notification listener. Add a guard for header existence and wrap the parse in a try/catch.
🛡️ Proposed defensive guard
- const directoryInfos: DirectoryInfos[] = JSON.parse(eventData.headers[DIRECTORIES_INFOS]);
- if (directoryInfos.some((info) => studyParentDirectoriesUuidsRef.current.includes(info.uuid))) {
- fetchStudyPath();
- }
+ const rawInfos = eventData.headers[DIRECTORIES_INFOS];
+ if (rawInfos) {
+ try {
+ const directoryInfos: DirectoryInfos[] = JSON.parse(rawInfos);
+ if (directoryInfos.some((info) => studyParentDirectoriesUuidsRef.current.includes(info.uuid))) {
+ fetchStudyPath();
+ }
+ } catch {
+ // Ignore malformed payload
+ }
+ }📝 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.
| const directoryInfos: DirectoryInfos[] = JSON.parse(eventData.headers[DIRECTORIES_INFOS]); | |
| if (directoryInfos.some((info) => studyParentDirectoriesUuidsRef.current.includes(info.uuid))) { | |
| const rawInfos = eventData.headers[DIRECTORIES_INFOS]; | |
| if (rawInfos) { | |
| try { | |
| const directoryInfos: DirectoryInfos[] = JSON.parse(rawInfos); | |
| if (directoryInfos.some((info) => studyParentDirectoriesUuidsRef.current.includes(info.uuid))) { | |
| fetchStudyPath(); | |
| } | |
| } catch { | |
| // Ignore malformed payload | |
| } | |
| } |
🤖 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/hooks/use-study-path.ts` around lines 71 - 72, In the WebSocket message
handler, guard access to the DIRECTORIES_INFOS header before parsing and wrap
JSON.parse in a try/catch to handle absent or malformed values without escaping
the callback. Update the directory-processing logic in the onMessage callback to
continue safely when parsing fails, while preserving the existing
studyParentDirectoriesUuidsRef.current matching behavior.
|



PR Summary