Skip to content

fix(api): keep excludent productClusterIds as repeated path facets - #3433

Merged
eduardoformiga merged 1 commit into
devfrom
fix/excludent-collection-facets
Aug 4, 2026
Merged

eduardoformiga merged 1 commit into
devfrom
fix/excludent-collection-facets

Conversation

@manuellacorreia

@manuellacorreia manuellacorreia commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Fix a FastStore Intelligent Search bug (found while triaging a report on the odpstage account, Slack thread) where an excludent collection filter silently does nothing: products from an excluded productClusterIds cluster keep showing up even though the session facets correctly ask to exclude them.

How it works?

Since the IS v1 migration, intelligentSearchRequest.ts treated productClusterIds segment facets as a single query param, stored in a plain JS object keyed by productClusterIds. When the session sends two facets sharing that key — one inclusion (productClusterIds=80182) and one exclusion (productClusterIds=not:80183) — the second silently overwrites the first in the object, and the one value that survives is still sent in the wrong shape: a singular productClusterId query param, which Intelligent Search does not recognize.

IS actually expects each occurrence as a repeated path segment (confirmed with a manual request against the account's IS endpoint):

.../product_search/productClusterIds/80182/productClusterIds/not:80183

The fix removes the special single-value query-param handling for productClusterIds so it flows through the same extraFacets/path pipeline as any other repeated facet, producing the correct repeated path segments.

How to test it?

  • Unit tests added/updated in packages/api/test/unit/platforms/vtex/utils/intelligentSearchRequest.test.ts:
    • Updated the existing productClusterIds cookie test to assert the corrected path-based output.
    • Added a new test reproducing the reported scenario (simultaneous inclusion + exclusion facets), asserting both survive as separate path segments and that no productClusterId query param is emitted anymore.
  • Ran the full packages/api unit suite locally: all tests passing.
  • Reproduced locally against the affected account's real discovery config (with CMS tenant set to vtex defaults) to confirm this is a framework bug, not an account customization issue, before implementing the fix.

References

Reported and investigated in an internal Slack thread (Search & Recommendation team) about the odpstage account's excludent collection filter not working on Intelligent Search.

Checklist

  • PR title and commit messages follow the Conventional Commits specification
  • Added a label according to the PR goal
  • No pnpm-lock.yaml changes (no dependency changes)
  • PR description filled

Summary by CodeRabbit

  • Bug Fixes
    • Corrected product-cluster filtering so inclusion and exclusion facets are preserved in the request path.
    • Prevented product-cluster filters from being incorrectly converted into query parameters.
    • Preserved repeated facet keys for more accurate search requests.

Segment facets sharing the productClusterIds key (e.g. an inclusion and
an exclusion cluster) were collapsed into a single query param via a
plain object, so the last one silently overwrote the others. The
surviving value was then sent as a singular `productClusterId` query
param, a shape Intelligent Search does not recognize — it expects each
occurrence as a repeated path segment
(productClusterIds/X/productClusterIds/not:Y/), same as any other
facet.

productClusterIds now flows through the existing extraFacets/path
pipeline like other repeated facets, instead of through a
single-value query param.
@manuellacorreia
manuellacorreia requested a review from a team as a code owner August 4, 2026 14:14
@manuellacorreia manuellacorreia added bug Something isn't working contributing Pull request submitted by the community labels Aug 4, 2026
@manuellacorreia
manuellacorreia requested review from gabpaladino and renatomaurovtex and removed request for a team August 4, 2026 14:14
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d2510b0e-c328-4762-9289-5a0cde0e20c6

📥 Commits

Reviewing files that changed from the base of the PR and between a160ca1 and 3103e86.

📒 Files selected for processing (2)
  • packages/api/src/platforms/vtex/utils/intelligentSearchRequest.ts
  • packages/api/test/unit/platforms/vtex/utils/intelligentSearchRequest.test.ts

Walkthrough

The VTEX request builder no longer converts productClusterIds facets into query parameters. It preserves these facets as extra path segments, including repeated inclusion and exclusion values. Unit tests update existing expectations and cover separate encoded segments.

Changes

VTEX product cluster facet serialization

Layer / File(s) Summary
Serialize product cluster facets in the request path
packages/api/src/platforms/vtex/utils/intelligentSearchRequest.ts
The request builder removes productClusterIds from segment and query-parameter handling. Facet parsing retains all non-shipping facets for path generation, including repeated product cluster values.
Validate repeated product cluster path segments
packages/api/test/unit/platforms/vtex/utils/intelligentSearchRequest.test.ts
Tests expect productClusterIds in the request path and verify separate encoded inclusion and exclusion segments without productClusterId query parameters.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • vtex/faststore#3385: Modifies the same request builder and unit tests for productClusterIds serialization.

Suggested reviewers: gabpaladino, renatomaurovtex

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preserving exclusion productClusterIds as repeated path facets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/excludent-collection-facets

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.

@codesandbox-ci

codesandbox-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@sonar-workflows

Copy link
Copy Markdown

@manuellacorreia
manuellacorreia requested review from eduardoformiga and removed request for gabpaladino August 4, 2026 14:25
Comment on lines +178 to +180
// NOTE: productClusterIds (and any other repeated facet key, e.g. for
// excludent collections) must stay as path segments, not collapse into
// a single query param — IS expects productClusterIds/X/productClusterIds/not:Y/.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

@eduardoformiga
eduardoformiga merged commit 3ad86bf into dev Aug 4, 2026
11 checks passed
@eduardoformiga
eduardoformiga deleted the fix/excludent-collection-facets branch August 4, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working contributing Pull request submitted by the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants