[CDX-443] Fix rex bug with pod ID conflicts#279
Open
esezen wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Code Review
This PR correctly fixes the pod ID collision bug by introducing a composite cache key (podId::indexSectionName) and also fixes an inverted guard in useSections. The changes are well-scoped and include meaningful test coverage.
Inline comments: 5 discussions added
Overall Assessment:
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two recommendation pods with the same
podIdbut differentindexSectionName(e.g.bestsellerstargeting bothProductsandSearch Suggestions) were collapsing into a single result set because the internal cache was keyed bypodIdalone.useFetchRecommendationPodwrote bothrecommendationsResultsandpodsDataas{ [podId]: ... }. The second API response silently overwrote the first, and every downstream reader (helpers,useActiveSections,useCioAutocomplete, React keys, view tracking) inherited the collision.getRecommendationPodKey(podId, indexSectionName)helper producing${podId}::${indexSectionName ?? 'Products'}, threaded through every write and read site.useSections(if (!podsData)→if (podsData)) so the local state actually hydrates.trackRecommendationViewnow disambiguates onpodId+indexSectionNameso view events attribute to the correct section.data-cnstrc-sectionon recommendation containers falls back toindexSectionNamewhen the pod returns zero results.Breaking change
podsDatareturned fromuseCioAutocompleteis now keyed by the composite key instead of barepodId. External consumers reading this map by barepodIdwill need to update the lookup.Public types, SDK request shape, and tracking payload are unchanged.