Skip to content

fix: seq becoming NaN when moving requests to collection root#6727

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
sanjaikumar-bruno:fix/seq-nan-on-root-move
Jan 8, 2026
Merged

fix: seq becoming NaN when moving requests to collection root#6727
bijin-bruno merged 1 commit intousebruno:mainfrom
sanjaikumar-bruno:fix/seq-nan-on-root-move

Conversation

@sanjaikumar-bruno
Copy link
Member

@sanjaikumar-bruno sanjaikumar-bruno commented Jan 7, 2026

BRU-2443
Fixes: #6232

Cause:
Logic inside handleCollectionItemDrop function used findIndex (returns a number) instead of find (returns the item), so accessing .seq on the index returned undefined, which became NaN.

Fix:

  1. Changed findIndex to find to get the item's seq.
  2. Added an early return to discard the operation when dragging a root item to the collection name (same location).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

Walkthrough

Bug fix to drag-and-drop handling in collection item reordering. Changed seq computation from using item index to using sequence value for adjacent drops, and added guard to prevent moving root items to collection root, resolving NaN seq assignment issues.

Changes

Cohort / File(s) Summary
Drag-and-Drop Seq Computation Fix
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
Changed adjacent drop seq calculation from findIndex() (position-based) to find() (value-based). Added guard clause to prevent root-level items from being moved to collection root in non-cross-collection scenarios, returning early to avoid NaN seq assignment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🐉 A request flew high, then fell to the ground,
Its seq turned to NaN with nary a sound.
Now guards stand watch at the root's sacred gate,
And sequences flow with their proper true weight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main bug fix: correcting the NaN seq issue when moving requests to collection root.
Linked Issues check ✅ Passed The PR successfully addresses issue #6232 by fixing the findIndex-to-find logic and preventing invalid root-level moves.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to fixing the seq NaN bug in drag-and-drop operations; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9005e17 and 2b77d66.

📒 Files selected for processing (1)
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
🧬 Code graph analysis (1)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (1)
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js (16)
  • collection (113-113)
  • collection (148-148)
  • collection (154-154)
  • collection (162-162)
  • collection (168-168)
  • collection (175-175)
  • collection (182-182)
  • collection (214-214)
  • collection (223-223)
  • collection (232-232)
  • collection (244-244)
  • collection (252-252)
  • collection (264-264)
  • collection (279-279)
  • collection (296-296)
  • collection (303-303)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: CLI Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
🔇 Additional comments (2)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)

1132-1132: Excellent fix for the NaN bug.

Changing from findIndex to find correctly resolves the issue. Previously, findIndex returned the array index (a number), and accessing .seq on a number returned undefined, which caused the seq to become NaN. Now find returns the item object itself, allowing proper access to its seq property.


179-186: Clean guard logic to prevent no-op moves.

The early return correctly identifies and discards the operation when dragging a root item onto the collection name (same location). The three-condition check ensures:

  1. Target is the collection root
  2. Dragged item is already at root
  3. Not a cross-collection move

This prevents unnecessary resequencing operations.


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.

@bijin-bruno bijin-bruno merged commit 4708e8e into usebruno:main Jan 8, 2026
8 checks passed
@sanjaikumar-bruno sanjaikumar-bruno deleted the fix/seq-nan-on-root-move branch January 8, 2026 09:09
@coderabbitai coderabbitai bot mentioned this pull request Feb 24, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request seq is set to NaN when moving it to the top folder

2 participants