fix: prevent ArrayIndexOutOfBoundsException in provider autocomplete search#2485
fix: prevent ArrayIndexOutOfBoundsException in provider autocomplete search#2485D3V41 wants to merge 1 commit into
Conversation
…on trailing comma
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts provider autocomplete search string splitting to safely handle trailing commas and removes a redundant array allocation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesProvider search parsing fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Code Review
This pull request updates the searchProvider method in ProviderData.java to use split(",", -1) when parsing the search string. This ensures that trailing empty strings are preserved (e.g., when a user inputs 'lastname,'), preventing an ArrayIndexOutOfBoundsException when accessing the split array. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider defensively checking the length of the
arraybefore accessing index 1 to make the parsing more resilient to unexpected input formats (e.g., multiple commas or unusual whitespace). - The new comment block is a bit verbose; you could tighten it to a single concise sentence describing the use of
split(",", -1)to preserve trailing empty tokens and avoid the exception.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider defensively checking the length of the `array` before accessing index 1 to make the parsing more resilient to unexpected input formats (e.g., multiple commas or unusual whitespace).
- The new comment block is a bit verbose; you could tighten it to a single concise sentence describing the use of `split(",", -1)` to preserve trailing empty tokens and avoid the exception.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Problem
Typing a lastname followed by a comma (e.g.
la,) in the provider autocomplete input throwsArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1atProviderData.searchProvider().searchStr.split(",")drops trailing empty strings, so"la,"returns["la"]. Accessingarray[1]for the firstname then fails.Fix
Use
split(",", -1)so the trailing empty field is preserved (["la", ""]). The firstname becomes an empty string and the search runs normally. Also removed a redundantnew String[2]allocation that was immediately overwritten.Summary by Sourcery
Bug Fixes:
Summary by cubic
Prevent ArrayIndexOutOfBoundsException in provider autocomplete when a user types a lastname followed by a comma (e.g., "la,") by preserving the empty firstname during split. Also removes a redundant array allocation.
Written for commit 337d3ed. Summary will update on new commits.
Summary by CodeRabbit