Skip to content

fix: sbom Search by name instead of full search#1134

Merged
carlosthe19916 merged 1 commit into
guacsec:mainfrom
carlosthe19916:hotfix/sbom-search-name
Jul 2, 2026
Merged

fix: sbom Search by name instead of full search#1134
carlosthe19916 merged 1 commit into
guacsec:mainfrom
carlosthe19916:hotfix/sbom-search-name

Conversation

@carlosthe19916

@carlosthe19916 carlosthe19916 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes https://redhat.atlassian.net/browse/TC-5046

The Search page (/search) was sending SBOM API requests as:

  GET /api/v3/sbom?q=~INPUT_TEXT

This performs a full-text search across all fields. As Requested in the jira linked above, for performance reasons we should change it to:

  GET /api/v3/sbom?q=name~INPUT_TEXT

What changed

  • Main search submission: When the user types in the search bar and presses Enter, the SBOM endpoint now receives q=name~INPUT_TEXT instead of q=~INPUT_TEXT
  • Autocomplete dropdown: The real-time SBOM suggestions while typing also use q=name~INPUT_TEXT
  • Sidebar filter: The "Filter text" filter is hidden from the left sidebar on the SBOM tab, since the top search bar already handles it
  • Other tabs unaffected: Package, Vulnerability, and Advisory endpoints still use full-text search (q=~INPUT_TEXT) as before

Related Issues

guacsec/trustify#2440

Summary by Sourcery

Update SBOM search to query by name instead of full-text and align UI filters with the new search behavior.

Bug Fixes:

  • Change SBOM API queries on the search page and autocomplete to use a name-based filter instead of full-text search, addressing performance concerns.

Enhancements:

  • Align SBOM table filter state and filter panel configuration with the new name-based search field, including updating filter keys and omitted categories.

Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts SBOM search behavior so that both the main search and autocomplete query the SBOM API by name only, and aligns SBOM filter configuration/types so that the name filter is driven from the top search bar while the sidebar text filter is hidden for SBOMs but other entity searches remain unchanged.

Sequence diagram for updated SBOM search by name

sequenceDiagram
  actor User
  participant Search as SearchPage
  participant SearchMenu
  participant useAllEntities
  participant useFetchSBOMs
  participant SBOM_API

  User->>Search: type searchValue
  User->>Search: press Enter
  Search->>SearchMenu: set searchValue
  SearchMenu->>useAllEntities: useAllEntities(filterText, disableSearch)
  useAllEntities->>useFetchSBOMs: useFetchSBOMs(null, sbomParams, [], disableSearch)
  note over useAllEntities,useFetchSBOMs: sbomParams.filters = [ { field: name, operator: ~, value: filterText } ]
  useFetchSBOMs->>SBOM_API: GET /api/v3/sbom?q=name~filterText
  SBOM_API-->>useFetchSBOMs: sbom results
  useFetchSBOMs-->>useAllEntities: sboms
  useAllEntities-->>SearchMenu: suggestions and results
  SearchMenu-->>User: updated SBOM search and autocomplete
Loading

File-Level Changes

Change Details Files
Update SBOM autocomplete/search queries to use name-scoped search instead of full-text search.
  • Introduce dedicated sbomParams that filter on the name field with the '~' operator when querying SBOMs.
  • Switch useFetchSBOMs to use sbomParams instead of the generic params used by other entities.
client/src/app/pages/search/components/SearchMenu.tsx
Align SBOM filter state and UI to use the name field as the primary search key and hide the redundant sidebar filter for SBOMs.
  • Change appliedSearchValue for SBOM tab to read from the name filter key instead of a generic FILTER_TEXT_CATEGORY_KEY.
  • Update SearchTabs SBOM filter panel type to include 'name' and configure omitFilterCategoryKeys to omit 'name' so the sidebar filter is hidden.
  • Adjust SBOM search context generic type to enumerate 'name' as an allowed filter key.
  • Change SbomSearchProvider filterCategories so the search filter categoryKey is 'name' instead of the generic FILTER_TEXT_CATEGORY_KEY while keeping the label/title unchanged.
  • Update the main Search page submission logic so SBOM filterState writes the search value to the 'name' filter key, leaving other tabs unchanged.
client/src/app/pages/search/components/SearchMenu.tsx
client/src/app/pages/search/components/SearchTabs.tsx
client/src/app/pages/sbom-list/sbom-context.ts
client/src/app/pages/sbom-list/sbom-provider.tsx
client/src/app/pages/search/search.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've found 1 issue, and left some high level feedback:

  • The string literal "name" is now duplicated in several places (filter categories, omitFilterCategoryKeys, filterState usage); consider centralizing it in a shared constant or type-safe enum to avoid drift and typos.
  • Since the SBOM filter panel now hides the name filter while still configuring it in the provider, it may be worth clarifying whether the label/placeholder (currently "Filter text") and behavior are still appropriate given it only targets the name field.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The string literal "name" is now duplicated in several places (filter categories, omitFilterCategoryKeys, filterState usage); consider centralizing it in a shared constant or type-safe enum to avoid drift and typos.
- Since the SBOM filter panel now hides the name filter while still configuring it in the provider, it may be worth clarifying whether the label/placeholder (currently "Filter text") and behavior are still appropriate given it only targets the name field.

## Individual Comments

### Comment 1
<location path="client/src/app/pages/sbom-list/sbom-provider.tsx" line_range="75" />
<code_context>
     filterCategories: [
       {
-        categoryKey: FILTER_TEXT_CATEGORY_KEY,
+        categoryKey: "name",
         title: "Filter text",
         placeholderText: "Search",
</code_context>
<issue_to_address>
**suggestion:** Consider centralizing the `"name"` filter key instead of hardcoding it.

This key is now referenced in multiple places (provider, search menu, search tabs, `setFilterValues`, etc.), so hardcoding it in each file increases the risk of inconsistencies if it ever changes. Exposing a shared constant (like the previous `FILTER_TEXT_CATEGORY_KEY`) and reusing it would keep the key definition in one place and make future changes safer.

Suggested implementation:

```typescript
    isFilterEnabled: true,
    filterCategories: [
      {
        categoryKey: FILTER_TEXT_CATEGORY_KEY,
        title: "Filter text",
        placeholderText: "Search",
        type: FilterType.search,

```

1. Ensure `FILTER_TEXT_CATEGORY_KEY` is defined in a shared constants module (e.g. `client/src/app/pages/sbom-list/constants.ts` or an existing filters-constants file), with a value of `"name"`, and exported:
   - `export const FILTER_TEXT_CATEGORY_KEY = "name";`
2. Import `FILTER_TEXT_CATEGORY_KEY` at the top of `sbom-provider.tsx` from that shared constants module:
   - `import { FILTER_TEXT_CATEGORY_KEY } from "./constants";` (or the correct relative path for your project).
3. In all other places that currently hardcode `"name"` for this same filter (provider, search menu, search tabs, `setFilterValues`, etc.), replace the string literal with `FILTER_TEXT_CATEGORY_KEY` and add the same import there. This keeps the filter key centralized and consistent.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

filterCategories: [
{
categoryKey: FILTER_TEXT_CATEGORY_KEY,
categoryKey: "name",

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.

suggestion: Consider centralizing the "name" filter key instead of hardcoding it.

This key is now referenced in multiple places (provider, search menu, search tabs, setFilterValues, etc.), so hardcoding it in each file increases the risk of inconsistencies if it ever changes. Exposing a shared constant (like the previous FILTER_TEXT_CATEGORY_KEY) and reusing it would keep the key definition in one place and make future changes safer.

Suggested implementation:

    isFilterEnabled: true,
    filterCategories: [
      {
        categoryKey: FILTER_TEXT_CATEGORY_KEY,
        title: "Filter text",
        placeholderText: "Search",
        type: FilterType.search,
  1. Ensure FILTER_TEXT_CATEGORY_KEY is defined in a shared constants module (e.g. client/src/app/pages/sbom-list/constants.ts or an existing filters-constants file), with a value of "name", and exported:
    • export const FILTER_TEXT_CATEGORY_KEY = "name";
  2. Import FILTER_TEXT_CATEGORY_KEY at the top of sbom-provider.tsx from that shared constants module:
    • import { FILTER_TEXT_CATEGORY_KEY } from "./constants"; (or the correct relative path for your project).
  3. In all other places that currently hardcode "name" for this same filter (provider, search menu, search tabs, setFilterValues, etc.), replace the string literal with FILTER_TEXT_CATEGORY_KEY and add the same import there. This keeps the filter key centralized and consistent.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.07%. Comparing base (662165e) to head (60c6a17).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1134      +/-   ##
==========================================
- Coverage   53.08%   53.07%   -0.02%     
==========================================
  Files         270      270              
  Lines        5879     5879              
  Branches     1843     1842       -1     
==========================================
- Hits         3121     3120       -1     
  Misses       2455     2455              
- Partials      303      304       +1     
Flag Coverage Δ
e2e 70.67% <100.00%> (-0.02%) ⬇️
unit 7.01% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carlosthe19916 carlosthe19916 enabled auto-merge July 2, 2026 17:40
@carlosthe19916 carlosthe19916 added the backport release/0.5.z This PR should be backported to release/0.5.z branch. label Jul 2, 2026

@CryptoRodeo CryptoRodeo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@carlosthe19916 carlosthe19916 added this pull request to the merge queue Jul 2, 2026
Merged via the queue into guacsec:main with commit 2e45be3 Jul 2, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Trustify Jul 2, 2026
@trustify-ci-bot

Copy link
Copy Markdown
Contributor

Backport failed for release/0.5.z, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release/0.5.z
git worktree add -d .worktree/backport-1134-to-release/0.5.z origin/release/0.5.z
cd .worktree/backport-1134-to-release/0.5.z
git switch --create backport-1134-to-release/0.5.z
git cherry-pick -x 2e45be37c561d10f0506935e82f48654f8fff974

@carlosthe19916

Copy link
Copy Markdown
Collaborator Author

/backport

@trustify-ci-bot

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release/0.5.z:

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

Labels

backport release/0.5.z This PR should be backported to release/0.5.z branch.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants