Skip to content

Fixed Inaccurate 'No Result Found' Behavior and corrected package-lock.json#6

Open
Pranay22077 wants to merge 1 commit into
gafreax:masterfrom
Pranay22077:bug
Open

Fixed Inaccurate 'No Result Found' Behavior and corrected package-lock.json#6
Pranay22077 wants to merge 1 commit into
gafreax:masterfrom
Pranay22077:bug

Conversation

@Pranay22077

Copy link
Copy Markdown

The issue: Inaccurate "No Result Found" Behavior has been fixed
image

In the process, 3 vulnerabilities (2 low, 1 moderate) were found in src/package-lock.json which are also corrected
image

…k.json

Signed-off-by: Pranay <pranaygadh_mc24b06_003@dtu.ac.in>
@Pranay22077

Copy link
Copy Markdown
Author

Hi @gafreax
The issue #5 has been resolved and the PR has been created
Kindly review the PR

Thanks

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the "No Result Found" behavior by implementing more accurate filtering of search results and adds proper error handling. The key improvement is that results are now filtered to only include packages whose names actually contain the search term, preventing false "no results" messages.

Key Changes

  • Added try-catch error handling in the search function to gracefully handle API failures
  • Implemented client-side filtering in trova to show only relevant results matching the search term
  • Made the action handler async with proper error handling using parseAsync

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/index.js
spinner.succeed(`Search complete for ${param}`) // Use succeed on success
return JSON.parse(result)
} catch (error) {
spinner.fail(`Search failed for ${param}: ${error.message}`) // Use fail on error

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

The spinner.fail() is called but the function continues to return a value instead of re-throwing the error. This could mask API failures from the caller. Consider either re-throwing the error or documenting why silent failure with empty results is the intended behavior.

Copilot uses AI. Check for mistakes.
Comment thread src/index.js

// --- Refined Check ---
// Filter for results where the package name actually includes the search term
const relevantResults = objects && objects.filter(obj =>

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

If objects is undefined or null (which can happen when search returns { objects: [] } on error), objects.filter will throw a TypeError. The conditional check objects && protects the filter call, but if objects is undefined, relevantResults will be undefined, not an empty array. This will cause the length check on line 60 to fail. Consider using objects?.filter() or (objects || []).filter() to ensure relevantResults is always an array.

Suggested change
const relevantResults = objects && objects.filter(obj =>
const relevantResults = (objects || []).filter(obj =>

Copilot uses AI. Check for mistakes.
Comment thread src/index.js
await trova(name, options) // Await the async trova function
} else {
console.log(chalk.red('No search term provided'))
program.help(); // Show help if no argument provided

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

This condition block (lines 89-92) is unreachable. Commander.js enforces required arguments defined with .argument('<name>'), so the action handler will never be called if the name argument is missing. The framework will automatically display help and exit before reaching this code.

Copilot uses AI. Check for mistakes.
Comment thread src/index.js
console.log(chalk.red(`❌ No relevant results found for query: ${name}`))
// Optional: Log if the original search returned *something*, but nothing relevant
if (objects && objects.length > 0) {
console.log(chalk.yellow(` (Note: The API returned ${objects.length} loosely related package(s).)`));

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling: 'package(s).)' should be 'package(s)).' - the period should come before the closing parenthesis.

Suggested change
console.log(chalk.yellow(` (Note: The API returned ${objects.length} loosely related package(s).)`));
console.log(chalk.yellow(` (Note: The API returned ${objects.length} loosely related package(s)).`));

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@gafreax
Are the changes made fine?
If yes, request you to merge the PR
Thanks

@gafreax gafreax self-assigned this Oct 23, 2025
@Pranay22077

Copy link
Copy Markdown
Author

Hi @gafreax
Hope the issue has been resolved
If yes, kindly merge the PR

Thanks

@gafreax

gafreax commented Oct 26, 2025

Copy link
Copy Markdown
Owner

Hi @Pranay22077, please fix the suggestion in the comments, then I will check again!

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.

3 participants