Skip to content

fix(opensource): trim search query before database lookup#1218

Open
mayank200529 wants to merge 6 commits into
Sachinchaurasiya360:mainfrom
mayank200529:fix-search-trim
Open

fix(opensource): trim search query before database lookup#1218
mayank200529 wants to merge 6 commits into
Sachinchaurasiya360:mainfrom
mayank200529:fix-search-trim

Conversation

@mayank200529
Copy link
Copy Markdown
Contributor

@mayank200529 mayank200529 commented Jun 3, 2026

Pull Request

Description

Fixed whitespace-only search queries triggering unnecessary database lookups in the Open Source module.

Changes

  • Updated opensource.routes.ts to trim search input before processing.
  • Updated opensource.service.ts to trim search input before applying filters.
  • Prevents whitespace-only queries from hitting the database.
  • Uses trimmed search values consistently across search operations.

Related Issue

Fixes #1000

Type of Change

  • Bug Fix
  • Feature
  • Enhancement
  • Documentation

Testing

Tested the following scenarios:

  1. Normal search query (?search=react) works correctly.
  2. Search query with leading/trailing spaces (?search= react ) is trimmed and works correctly.
  3. Whitespace-only search query (?search= ) no longer triggers unnecessary database filtering.

Screenshots / Video

No UI changes in this PR

Checklist

  • Code follows project guidelines
  • No new compile/type errors
  • Tested manually (include steps above)
  • No .env, credentials, or node_modules committed
  • Docs updated (if needed)
  • Screenshot or video attached for every UI change (not applicable)

Summary by CodeRabbit

  • Bug Fixes

    • Improved open-source project search: trims whitespace, skips empty searches, and consistently applies trimmed input across name/description/tag filters to reduce unnecessary queries.
  • Chores

    • Removed the previously public GSOC organizations endpoint (no replacement provided).

@github-actions github-actions Bot added bug Something isn't working gssoc scope:backend Changes to server-side / API code gssoc:approved Approved for GSSoC scoring labels Jun 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Hi @mayank200529, 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 level:beginner Good for first-time contributors quality:exceptional Exceptional implementation quality type:bug Bug fixes labels Jun 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

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
📝 Walkthrough

Walkthrough

Service listRepos and getGsocOrgs trim the search input and only add OR-predicates when the trimmed value is non-empty; listRepos shows unresolved merge markers for some predicates. The opensource router import shows a leading BOM and the public GET /gsoc/orgs route registration was removed.

Changes

Whitespace-trimmed optional search & route removal

Layer / File(s) Summary
Service: trim and gate search predicates
server/src/module/opensource/opensource.service.ts
listRepos and getGsocOrgs derive trimmedSearch = search?.trim() and only construct where.OR when trimmedSearch is non-empty; name/owner/description predicates and tag ILIKE use trimmedSearch. listRepos contains unresolved conflict markers affecting description and language filters.
Router: BOM and removed GET /gsoc/orgs
server/src/module/opensource/opensource.routes.ts
Top-level import shows a leading BOM on the Router import and retains prisma; the public GET /gsoc/orgs route registration was removed and nearby route boundary lines were adjusted.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

quality:clean

Suggested reviewers

  • Sachinchaurasiya360

Poem

🐰 I trimmed the search, no spaces remain,
The router lost a route, a tidy domain,
Queries now skip empty, logic crisp and neat,
Hopping through diffs with nimble little feet,
A tiny fix landed — code feels complete.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The raw summary indicates the GET /gsoc/orgs route was removed from opensource.routes.ts without a replacement, which appears unrelated to the stated objective of trimming search queries. Clarify whether removing the /gsoc/orgs route is intentional and related to issue #1000, or revert this change as it appears out of scope for the search trimming fix.
Linked Issues check ❓ Inconclusive The PR addresses issue #1000 by trimming search input in both routes and service files; however, the raw summary indicates an unresolved merge conflict in opensource.service.ts affecting the search filter logic. Resolve the merge conflict in opensource.service.ts affecting the 'description' and 'language' contains predicates to ensure trimmed search values are applied consistently across all filters.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(opensource): trim search query before database lookup' clearly and concisely summarizes the main change—trimming search input to prevent unnecessary database queries.
Description check ✅ Passed The description covers all required template sections: description, related issue, type of change, testing scenarios, and checklist items, providing sufficient detail about the changes made.
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.

@mayank200529
Copy link
Copy Markdown
Contributor Author

Hi @Sachinchaurasiya360,

I have completed the fix and submitted a PR for this issue.

The implementation trims search input before processing and prevents whitespace-only queries from triggering unnecessary database lookups.

Thank you for reviewing.

@github-actions github-actions Bot added level:intermediate Requires moderate project understanding and removed level:beginner Good for first-time contributors labels Jun 4, 2026
@mayank200529
Copy link
Copy Markdown
Contributor Author

Hi @Sachinchaurasiya360,

I have completed the fix and submitted a PR for this issue.

The implementation trims search input before processing and prevents whitespace-only queries from triggering unnecessary database lookups.

Thank you for reviewing.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
server/src/module/opensource/opensource.routes.ts (2)

27-59: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Move /requests/mine handler logic to controller for consistency.

Lines 27-59 contain inline Prisma queries and business logic directly in the route handler, while all other routes in this file delegate to OpensourceController methods. This breaks the established layering pattern and violates the coding guideline that service layers should contain database queries.

Move this logic to a controller method (e.g., controller.getMyRepoRequests) to maintain architectural consistency and improve testability.

♻️ Suggested refactoring

In the routes file:

 // Get my repo requests
-opensourceRouter.get("/requests/mine", authMiddleware, requireRole("STUDENT"), async (req, res, next) => {
-  try {
-    const requests = await prisma.repoRequest.findMany({
-      where: { userId: req.user!.id },
-      orderBy: { createdAt: "desc" },
-    });
-
-    // For approved requests, look up the corresponding InternHack repo ID so
-    // the client can open the repo detail popup directly.
-    const approvedUrls = requests
-      .filter((r) => r.status === "APPROVED")
-      .map((r) => r.url);
-
-    const approvedRepos =
-      approvedUrls.length > 0
-        ? await prisma.opensourceRepo.findMany({
-            where: { url: { in: approvedUrls } },
-            select: { id: true, url: true },
-          })
-        : [];
-
-    const repoIdByUrl = new Map(approvedRepos.map((r) => [r.url, r.id]));
-
-    const enriched = requests.map((r) => ({
-      ...r,
-      repoId: r.status === "APPROVED" ? (repoIdByUrl.get(r.url) ?? null) : null,
-    }));
-
-    res.json({ requests: enriched });
-  } catch (err) {
-    next(err);
-  }
-});
+opensourceRouter.get("/requests/mine", authMiddleware, requireRole("STUDENT"), (req, res, next) =>
+  controller.getMyRepoRequests(req, res, next)
+);

Then add the corresponding method to OpensourceController.

🤖 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 `@server/src/module/opensource/opensource.routes.ts` around lines 27 - 59, The
route handler for opensourceRouter.get("/requests/mine") contains inline
DB/business logic (prisma.repoRequest, prisma.opensourceRepo and the
approvedUrls/repoIdByUrl mapping) and should be moved into a controller method
to match the rest of the file; create a method on OpensourceController (e.g.,
getMyRepoRequests) that accepts the current user (or req) and performs the same
prisma.repoRequest.findMany, prisma.opensourceRepo.findMany, mapping to repoId,
and returns the enriched requests, then replace the inline handler body with a
call/delegation to OpensourceController.getMyRepoRequests(...)/its returned
result and let the route only handle auth/role and response handling (res.json
or next(err)).

11-86: ⚠️ Potential issue | 🟠 Major

Add usageLimit(action) middleware (or document an explicit exemption) for opensource routes
server/src/module/opensource/opensource.routes.ts registers /requests, /requests/mine, /requests/all, and /requests/:id/approve|reject without usageLimit(action) in the middleware chain. Coding guidelines require enforcing daily usage limits via usageLimit(action) with actions ATS_SCORE, COVER_LETTER, GENERATE_RESUME, JOB_APPLICATION, and MOCK_INTERVIEW; either apply usageLimit(...) to the relevant endpoints or justify why opensource functionality is exempt.

🤖 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 `@server/src/module/opensource/opensource.routes.ts` around lines 11 - 86,
Routes under opensourceRouter (notably the student-authenticated POST
"/requests" -> submitRepoRequest, GET "/requests/mine", and GET
"/analytics/trend" -> getStudentContributionTrend) are missing the
usageLimit(action) middleware required by coding guidelines; either add the
usageLimit middleware with the appropriate action constant(s) (e.g.,
usageLimit(ATS_SCORE) / usageLimit(COVER_LETTER) / usageLimit(GENERATE_RESUME) /
usageLimit(JOB_APPLICATION) / usageLimit(MOCK_INTERVIEW)) into the middleware
chain for these endpoints or add a concise exemption comment at the top of
opensource.routes.ts explaining why opensource routes are excluded, referencing
the usageLimit function and the listed actions so reviewers can verify
compliance. Ensure you update both the inline route for "/requests/mine" and the
router registrations that call controller.submitRepoRequest and
controller.getStudentContributionTrend (and admin request handlers if they
should be limited) so the middleware ordering matches authMiddleware and
requireRole.
🤖 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.

Outside diff comments:
In `@server/src/module/opensource/opensource.routes.ts`:
- Around line 27-59: The route handler for
opensourceRouter.get("/requests/mine") contains inline DB/business logic
(prisma.repoRequest, prisma.opensourceRepo and the approvedUrls/repoIdByUrl
mapping) and should be moved into a controller method to match the rest of the
file; create a method on OpensourceController (e.g., getMyRepoRequests) that
accepts the current user (or req) and performs the same
prisma.repoRequest.findMany, prisma.opensourceRepo.findMany, mapping to repoId,
and returns the enriched requests, then replace the inline handler body with a
call/delegation to OpensourceController.getMyRepoRequests(...)/its returned
result and let the route only handle auth/role and response handling (res.json
or next(err)).
- Around line 11-86: Routes under opensourceRouter (notably the
student-authenticated POST "/requests" -> submitRepoRequest, GET
"/requests/mine", and GET "/analytics/trend" -> getStudentContributionTrend) are
missing the usageLimit(action) middleware required by coding guidelines; either
add the usageLimit middleware with the appropriate action constant(s) (e.g.,
usageLimit(ATS_SCORE) / usageLimit(COVER_LETTER) / usageLimit(GENERATE_RESUME) /
usageLimit(JOB_APPLICATION) / usageLimit(MOCK_INTERVIEW)) into the middleware
chain for these endpoints or add a concise exemption comment at the top of
opensource.routes.ts explaining why opensource routes are excluded, referencing
the usageLimit function and the listed actions so reviewers can verify
compliance. Ensure you update both the inline route for "/requests/mine" and the
router registrations that call controller.submitRepoRequest and
controller.getStudentContributionTrend (and admin request handlers if they
should be limited) so the middleware ordering matches authMiddleware and
requireRole.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 52a1db62-b1b1-47e1-85a7-07e6dc042954

📥 Commits

Reviewing files that changed from the base of the PR and between 58f4001 and 0f6a737.

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

@github-actions github-actions Bot added level:beginner Good for first-time contributors and removed level:intermediate Requires moderate project understanding labels Jun 5, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 `@server/src/module/opensource/opensource.service.ts`:
- Around line 24-30: The listRepos implementation uses the raw opts.search
(variable search) to build where.OR causing whitespace-only strings to bypass
the guard; update listRepos to mirror the getGsocOrgs pattern by trimming and
validating opts.search before using it (e.g., derive search =
opts.search?.trim() or similar) and only build where.OR when that trimmed search
is non-empty, so predicates like name/owner/description/tags are not created for
blank input.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87015bff-1b4c-4ca0-8883-86558c991d87

📥 Commits

Reviewing files that changed from the base of the PR and between 0f6a737 and fe036cf.

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

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 `@server/src/module/opensource/opensource.service.ts`:
- Around line 24-30: The listRepos implementation uses the raw opts.search
(variable search) to build where.OR causing whitespace-only strings to bypass
the guard; update listRepos to mirror the getGsocOrgs pattern by trimming and
validating opts.search before using it (e.g., derive search =
opts.search?.trim() or similar) and only build where.OR when that trimmed search
is non-empty, so predicates like name/owner/description/tags are not created for
blank input.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87015bff-1b4c-4ca0-8883-86558c991d87

📥 Commits

Reviewing files that changed from the base of the PR and between 0f6a737 and fe036cf.

📒 Files selected for processing (1)
  • server/src/module/opensource/opensource.service.ts
🛑 Comments failed to post (1)
server/src/module/opensource/opensource.service.ts (1)

24-30: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Apply the same trim-and-guard pattern to listRepos as used in getGsocOrgs.

The PR objectives explicitly state: "Apply the same trimming and validation in server/src/module/opensource/opensource.service.ts (listRepos) where opts.search is used." However, listRepos still uses raw search without trimming. Whitespace-only strings like " " will pass the if (search) check at line 24 and build OR predicates with meaningless search terms, triggering unnecessary database queries—the exact bug this PR claims to fix.

Apply the same pattern implemented in getGsocOrgs (lines 62-69) to ensure consistent behavior and complete the fix.

🔧 Proposed fix
   async listRepos(query: any) {
     const { page, limit, search, language, difficulty, domain, sortBy, sortOrder } = query;
     const skip = (page - 1) * limit;
 
     const where: any = {};
     if (language) where.language = language;
     if (difficulty) where.difficulty = difficulty;
     if (domain) where.domain = domain;
-    if (search) {
+    
+    const trimmedSearch = search?.trim();
+    if (trimmedSearch) {
       where.OR = [
-        { name: { contains: search, mode: "insensitive" } },
-        { owner: { contains: search, mode: "insensitive" } },
-        { description: { contains: search, mode: "insensitive" } },
-        { tags: { hasSome: [search] } },
+        { name: { contains: trimmedSearch, mode: "insensitive" } },
+        { owner: { contains: trimmedSearch, mode: "insensitive" } },
+        { description: { contains: trimmedSearch, mode: "insensitive" } },
+        { tags: { hasSome: [trimmedSearch] } },
       ];
     }
📝 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.

    if (language) where.language = language;
    if (difficulty) where.difficulty = difficulty;
    if (domain) where.domain = domain;

    const trimmedSearch = search?.trim();
    if (trimmedSearch) {
      where.OR = [
        { name: { contains: trimmedSearch, mode: "insensitive" } },
        { owner: { contains: trimmedSearch, mode: "insensitive" } },
        { description: { contains: trimmedSearch, mode: "insensitive" } },
        { tags: { hasSome: [trimmedSearch] } },
      ];
    }
🤖 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 `@server/src/module/opensource/opensource.service.ts` around lines 24 - 30, The
listRepos implementation uses the raw opts.search (variable search) to build
where.OR causing whitespace-only strings to bypass the guard; update listRepos
to mirror the getGsocOrgs pattern by trimming and validating opts.search before
using it (e.g., derive search = opts.search?.trim() or similar) and only build
where.OR when that trimmed search is non-empty, so predicates like
name/owner/description/tags are not created for blank input.

@mayank200529
Copy link
Copy Markdown
Contributor Author

Hi @Sachinchaurasiya360,

I have resolved the merge conflict and addressed the CodeRabbit feedback by using the trimmed search value consistently across the filters.

The PR now has no conflicts and can be cleanly merged.

Please let me know if any further changes are required.

Thank you!

@github-actions github-actions Bot added quality:clean Clean and well-structured contribution and removed quality:exceptional Exceptional implementation quality labels Jun 5, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/src/module/opensource/opensource.service.ts (1)

184-184: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix indentation inconsistency.

Extra leading spaces before if (trimmedSearch) — should align with surrounding code at 4 spaces.

🧹 Proposed fix
-      if (trimmedSearch) {
+    if (trimmedSearch) {
🤖 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 `@server/src/module/opensource/opensource.service.ts` at line 184, The line
with "if (trimmedSearch)" has extra leading spaces causing indentation
inconsistency in OpensourceService; locate the occurrence inside the method that
uses the trimmedSearch variable and align its indentation to 4 spaces to match
the surrounding block (adjust preceding whitespace so the "if (trimmedSearch)"
line and its enclosed block line up with other statements in that scope).
🤖 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 `@server/src/module/opensource/opensource.routes.ts`:
- Around line 28-48: There is an unresolved merge conflict around the Student
Progress Tracking routes; accept the upstream/main changes by removing the
conflict markers and keeping the added routes: ensure
opensourceRouter.get("/first-pr/progress", authMiddleware,
requireRole("STUDENT", ...)) calling controller.getFirstPrProgress and
opensourceRouter.patch("/first-pr/progress", authMiddleware,
requireRole("STUDENT", ...)) calling controller.patchFirstPrProgress remain in
the file and are placed before any "/:id" or "/requests/*" routes to avoid route
conflicts; remove the leftover <<<<<<<, =======, and >>>>>>> markers so the file
compiles cleanly.
- Around line 1-6: Remove the unresolved Git conflict markers (<<<<<<<, =======,
>>>>>>>) and the BOM character before the first import, and restore the upstream
import of prisma so the route handler that queries the database (the
/requests/mine route which uses prisma) compiles; specifically, keep a single
clean import block including: import { Router } from "express" and import {
prisma } from "../../database/db.js", then verify the route handler referencing
prisma (in the /requests/mine handler) uses that imported prisma instance.

In `@server/src/module/opensource/opensource.service.ts`:
- Around line 81-117: Remove the Git conflict markers (<<<<<<<, =======,
>>>>>>>) and resolve the merge by keeping the HEAD variant that consistently
uses trimmedSearch for all predicates; specifically ensure the block that runs
prisma.$queryRaw to compute tagMatches, maps to tagMatchIds, and builds
where["OR"] uses { name: { contains: trimmedSearch, mode: "insensitive" } }, {
owner: { contains: trimmedSearch, mode: "insensitive" } }, { description: {
contains: trimmedSearch, mode: "insensitive" } }, { language: { contains:
trimmedSearch, mode: "insensitive" } } and conditionally includes { id: { in:
tagMatchIds } } when tagMatchIds is non-empty (preserve tagMatches, tagMatchIds,
trimmedSearch, and where["OR"] identifiers).

---

Outside diff comments:
In `@server/src/module/opensource/opensource.service.ts`:
- Line 184: The line with "if (trimmedSearch)" has extra leading spaces causing
indentation inconsistency in OpensourceService; locate the occurrence inside the
method that uses the trimmedSearch variable and align its indentation to 4
spaces to match the surrounding block (adjust preceding whitespace so the "if
(trimmedSearch)" line and its enclosed block line up with other statements in
that scope).
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2baafbaa-f3bd-443d-a092-5ae3becaa1cd

📥 Commits

Reviewing files that changed from the base of the PR and between 1f70cc4 and 88fdf1b.

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

Comment on lines +1 to +6
<<<<<<< HEAD
import { Router } from "express";
=======
import { Router } from "express";
import { prisma } from "../../database/db.js";
>>>>>>> upstream/main
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Unresolved merge conflict markers break compilation.

The file contains unresolved Git conflict markers. Additionally, the HEAD side has a BOM (Byte Order Mark) character () before the import statement which should be removed.

The prisma import from upstream/main is required for the /requests/mine route (line 57).

🔧 Proposed resolution
-<<<<<<< HEAD
-import { Router } from "express";
-=======
 import { Router } from "express";
 import { prisma } from "../../database/db.js";
->>>>>>> upstream/main
📝 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.

Suggested change
<<<<<<< HEAD
import { Router } from "express";
=======
import { Router } from "express";
import { prisma } from "../../database/db.js";
>>>>>>> upstream/main
import { Router } from "express";
import { prisma } from "../../database/db.js";
🧰 Tools
🪛 Biome (2.4.16)

[error] 1-1: Expected a statement but instead found '<<<<<<< HEAD'.

(parse)


[error] 3-3: Expected a statement but instead found '======='.

(parse)


[error] 6-6: Expected a statement but instead found '>>>>>>> upstream/main'.

(parse)

🤖 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 `@server/src/module/opensource/opensource.routes.ts` around lines 1 - 6, Remove
the unresolved Git conflict markers (<<<<<<<, =======, >>>>>>>) and the BOM
character before the first import, and restore the upstream import of prisma so
the route handler that queries the database (the /requests/mine route which uses
prisma) compiles; specifically, keep a single clean import block including:
import { Router } from "express" and import { prisma } from
"../../database/db.js", then verify the route handler referencing prisma (in the
/requests/mine handler) uses that imported prisma instance.

Comment on lines 28 to +48
@@ -39,6 +45,7 @@ opensourceRouter.patch(
);

// ─── Repo Requests (Student-authenticated) ─────────────────────
>>>>>>> upstream/main
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Unresolved merge conflict in Student Progress Tracking section.

Resolve this conflict by accepting the upstream/main side which adds the new /first-pr/progress routes. These routes are correctly placed before /:id to avoid route conflicts, per coding guidelines.

🔧 Proposed resolution
-<<<<<<< HEAD
-=======
 // ─── Student Progress Tracking ─────────────────────────────────
 // NOTE: must be before /:id to avoid route conflicts

 opensourceRouter.get(
   "/first-pr/progress",
   authMiddleware,
   requireRole("STUDENT"),
   (req, res, next) => controller.getFirstPrProgress(req, res, next),
 );

 opensourceRouter.patch(
   "/first-pr/progress",
   authMiddleware,
   requireRole("STUDENT"),
   (req, res, next) => controller.patchFirstPrProgress(req, res, next),
 );

 // ─── Repo Requests (Student-authenticated) ─────────────────────
->>>>>>> upstream/main

Based on learnings: /requests/* routes must appear BEFORE /:id to avoid route conflicts.

🧰 Tools
🪛 Biome (2.4.16)

[error] 28-38: Expected a statement but instead found '<<<<<<< HEAD

// ─── Student Progress Tracking ─────────────────────────────────
// NOTE: must be before /:id to avoid route conflicts

opensourceRouter.get(
"/first-pr/progress",
authMiddleware,
requireRole("STUDENT"),
(req, res, next) => controller.getFirstPrProgress(req, res, next),
)'.

(parse)

🤖 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 `@server/src/module/opensource/opensource.routes.ts` around lines 28 - 48,
There is an unresolved merge conflict around the Student Progress Tracking
routes; accept the upstream/main changes by removing the conflict markers and
keeping the added routes: ensure opensourceRouter.get("/first-pr/progress",
authMiddleware, requireRole("STUDENT", ...)) calling
controller.getFirstPrProgress and opensourceRouter.patch("/first-pr/progress",
authMiddleware, requireRole("STUDENT", ...)) calling
controller.patchFirstPrProgress remain in the file and are placed before any
"/:id" or "/requests/*" routes to avoid route conflicts; remove the leftover
<<<<<<<, =======, and >>>>>>> markers so the file compiles cleanly.

Comment thread server/src/module/opensource/opensource.service.ts Outdated
@github-actions github-actions Bot added quality:exceptional Exceptional implementation quality and removed quality:clean Clean and well-structured contribution labels Jun 5, 2026
@mayank200529
Copy link
Copy Markdown
Contributor Author

Hi @Sachinchaurasiya360,

I investigated the failing CI / Typecheck Server check locally.

The failure does not appear to be caused by this PR specifically. Running the server typecheck reports a large number of existing TypeScript/Prisma-related errors across many unrelated modules in the repository (hundreds of errors across dozens of files), including modules that were not modified by this PR.

The changes in this PR are limited to the Open Source module and the intended search-trimming fix has been implemented successfully.

Could you please confirm whether the current typecheck failure is due to existing issues on the base branch? I’m happy to make any PR-specific adjustments if needed.

Thank you!

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:exceptional Exceptional implementation quality 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

1 participant