Skip to content

fix: trim search query before API call to prevent whitespace-only DB hits (#1000)#1413

Merged
Sachinchaurasiya360 merged 1 commit into
Sachinchaurasiya360:mainfrom
Xenon010101:fix/trim-search-query
Jun 5, 2026
Merged

fix: trim search query before API call to prevent whitespace-only DB hits (#1000)#1413
Sachinchaurasiya360 merged 1 commit into
Sachinchaurasiya360:mainfrom
Xenon010101:fix/trim-search-query

Conversation

@Xenon010101
Copy link
Copy Markdown
Contributor

@Xenon010101 Xenon010101 commented Jun 4, 2026

Fixes #1000

Summary by CodeRabbit

  • Bug Fixes
    • Search functionality now properly handles leading and trailing whitespace in queries across repository and organization listings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d409942a-5c66-4460-b2ff-59721fc7526c

📥 Commits

Reviewing files that changed from the base of the PR and between e15a36c and cb5d3f8.

📒 Files selected for processing (1)
  • server/src/module/opensource/opensource.service.ts

📝 Walkthrough

Walkthrough

Two methods in the opensource service now trim the incoming search parameter before use: listRepos trims into trimmedSearch and getGsocOrgs trims into gsocTrimmedSearch. Both methods skip their OR-clause filters entirely when the trimmed value is empty, preventing whitespace-only searches from querying the database.

Changes

Search Parameter Trimming

Layer / File(s) Summary
Trim search parameters in listRepos and getGsocOrgs
server/src/module/opensource/opensource.service.ts
Both listRepos (lines 28–47) and getGsocOrgs (lines 115–120) now trim their search parameters into local variables and apply filter OR-clauses only when trimmed values are non-empty, using the trimmed values in all tag-match and text-filter expressions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • Sachinchaurasiya360

Poem

🐰 With spaces trimmed from search so fine,
No whitespace queries hit the line,
Both repos and orgs now skip the dance,
When trimmed to nothing—filter's chance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is minimal and references the linked issue, but omits most required template sections like detailed description, testing approach, and the completion checklist. Expand the description to include implementation details, testing methodology, and complete the provided checklist items to ensure comprehensive documentation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: trimming search queries to prevent whitespace-only database hits, which directly matches the changeset.
Linked Issues check ✅ Passed The code changes implement trimming in both required files (opensource.routes.ts and opensource.service.ts), addressing the whitespace-only search problem specified in issue #1000.
Out of Scope Changes check ✅ Passed All changes are scoped to trimming search queries in the two specified files, directly addressing the linked issue requirements with no extraneous modifications.
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 unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added bug Something isn't working gssoc level:beginner Good for first-time contributors labels Jun 4, 2026
@github-actions github-actions Bot added the quality:clean Clean and well-structured contribution label Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Hi @Xenon010101, thanks for contributing to InternHack! 🎉

I have automatically:

  • 👤 Assigned this PR to you.
  • 🏷️ Applied the gssoc:approved label.

Our workflows will now analyze your changes to classify:

  • 📈 PR Difficulty: level:*
  • 🧩 PR Type: type:*
  • 🌟 PR Quality: quality:*

Tip

Ensure your PR description references the issue it resolves (e.g. Closes #123). This allows the bot to inherit any additional labels from that issue!

Happy coding! 🚀

@github-actions github-actions Bot added gssoc:approved Approved for GSSoC scoring scope:backend Changes to server-side / API code type:bug Bug fixes labels Jun 4, 2026
@Xenon010101 Xenon010101 force-pushed the fix/trim-search-query branch from 08e3ccb to cb5d3f8 Compare June 4, 2026 21:02
@Sachinchaurasiya360 Sachinchaurasiya360 merged commit 5e98bf0 into Sachinchaurasiya360:main Jun 5, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gssoc:approved Approved for GSSoC scoring gssoc level:beginner Good for first-time contributors quality:clean Clean and well-structured contribution scope:backend Changes to server-side / API code type:bug Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: search query not trimmed before API call — whitespace-only searches hit the database

2 participants