Skip to content

fix(search): ensure DefaultProvider callback is always executed (#32966)#38650

Open
Yashika-code wants to merge 3 commits into
RocketChat:developfrom
Yashika-code:fix/search-callback-not-called-32966
Open

fix(search): ensure DefaultProvider callback is always executed (#32966)#38650
Yashika-code wants to merge 3 commits into
RocketChat:developfrom
Yashika-code:fix/search-callback-not-called-32966

Conversation

@Yashika-code
Copy link
Copy Markdown
Contributor

@Yashika-code Yashika-code commented Feb 13, 2026

Proposed changes
Fixes an issue where DefaultProvider.search did not execute the callback when messageSearch returned a falsy value.

The update ensures:
Callback is always executed when provided.
Empty results are returned safely.
Errors are properly handled.
Search flow remains consistent and predictable.

Issue(s)
Closes #32966

Steps to test

Perform a room search with valid input.
Perform a search that returns no results.
Enable global search and repeat tests.
Verify that search responses are returned consistently.

Summary by CodeRabbit

  • Bug Fixes
    • Improved search reliability through enhanced error handling, ensuring graceful handling of edge cases and consistent result formatting across all scenarios.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 13, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 13, 2026

⚠️ No Changeset found

Latest commit: 526bab9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 13, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between f59bc92 and 526bab9.

📒 Files selected for processing (1)
  • apps/meteor/app/search/server/provider/DefaultProvider.ts
 ____________________________________________
< Double tap everything. Kill the bugs dead. >
 --------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

✏️ Tip: You can disable in-progress messages and the fortune message in your review settings.

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.


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.

@Yashika-code Yashika-code changed the title Fix/search callback not called 32966 fix(search): ensure DefaultProvider callback is always executed (#32966) Feb 13, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

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

🤖 Fix all issues with AI agents
In `@apps/meteor/app/search/server/provider/DefaultProvider.ts`:
- Around line 36-73: The search method (async search(...) in DefaultProvider) is
mis-indented: its parameter list and body are at the same level as the method
declaration instead of nested inside the method block; adjust the indentation so
the parameters, opening brace, and all statements inside the async search method
are indented one level (matching the constructor's indentation style) to restore
proper class method scope and readability.
🧹 Nitpick comments (2)
apps/meteor/app/search/server/provider/DefaultProvider.ts (2)

60-61: Remove the code comment.

As per coding guidelines, "Avoid code comments in the implementation" for **/*.{ts,tsx,js} files.

Proposed fix
-		// If SearchProvider expects promise-based handling
-		return;
+		return;

56-58: return callback(...) in an async method returns whatever the callback returns, not void.

Since search is declared async returning Promise<void>, and callback is typed to return void, this works in practice. However, if a caller ever changes the callback signature to return something, the return callback(...) pattern could cause subtle issues. This is a minor style point — using separate statements (callback(...); return;) would be more explicit, though not strictly required.

Optional: separate callback invocation from return
 		if (callback) {
-			return callback(null, safeResult);
+			callback(null, safeResult);
+			return;
 		}

Apply the same pattern to the error callback on lines 63–69.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f59bc92 and c52b020.

📒 Files selected for processing (1)
  • apps/meteor/app/search/server/provider/DefaultProvider.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/search/server/provider/DefaultProvider.ts
⏰ 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). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (1)
apps/meteor/app/search/server/provider/DefaultProvider.ts (1)

50-54: Verify that IRawSearchResult includes users and rooms fields.

The safe default includes users and rooms, but messageSearch may only return messages. If IRawSearchResult doesn't define users/rooms, this creates a type mismatch; if it does, confirm that messageSearch ever populates them.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines 36 to 73
async search(
userId: string,
text: string,
context: { uid?: IUser['_id']; rid: IRoom['_id'] },
payload: { searchAll?: boolean; limit?: number } = {},
callback?: (error: Error | null, result: IRawSearchResult) => void,
): Promise<void> {
userId: string,
text: string,
context: { uid?: IUser['_id']; rid: IRoom['_id'] },
payload: { searchAll?: boolean; limit?: number } = {},
callback?: (error: Error | null, result: IRawSearchResult) => void,
): Promise<void> {
try {
const _rid = payload.searchAll ? undefined : context.rid;

const _limit = payload.limit || this._settings.get<number>('PageSize');

const result = await messageSearch(userId, text, _rid, _limit);
if (callback && result !== false) {
return callback(null, result);

const safeResult: IRawSearchResult = result || {
messages: [],
users: [],
rooms: [],
};

if (callback) {
return callback(null, safeResult);
}

// If SearchProvider expects promise-based handling
return;
} catch (error) {
if (callback) {
return callback(error as Error, {
messages: [],
users: [],
rooms: [],
});
}

throw error;
}
}
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 | 🟡 Minor

Indentation: method body appears to be dedented one level from the class method scope.

The method parameters (lines 37–42) and the method body (lines 43–72) appear to be at the same indentation level as the method declaration, rather than being indented inside the method body block. Compare with the constructor (lines 14–23) where the body is indented one additional level.

#!/bin/bash
# Verify indentation of the search method body vs constructor body
fd "DefaultProvider.ts" --exec head -73 {} | cat -A | tail -40
🧰 Tools
🪛 Biome (2.3.14)

[error] 73-73: expected } but instead the file ends

the file ends here

(parse)

🤖 Prompt for AI Agents
In `@apps/meteor/app/search/server/provider/DefaultProvider.ts` around lines 36 -
73, The search method (async search(...) in DefaultProvider) is mis-indented:
its parameter list and body are at the same level as the method declaration
instead of nested inside the method block; adjust the indentation so the
parameters, opening brace, and all statements inside the async search method are
indented one level (matching the constructor's indentation style) to restore
proper class method scope and readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jump to message lead to room not found when searching messages

2 participants