Skip to content

[CDX-443] Fix rex bug with pod ID conflicts#279

Open
esezen wants to merge 3 commits into
mainfrom
cdx-443-autocomplete-recommendations-sections-share-data-by-pod-id
Open

[CDX-443] Fix rex bug with pod ID conflicts#279
esezen wants to merge 3 commits into
mainfrom
cdx-443-autocomplete-recommendations-sections-share-data-by-pod-id

Conversation

@esezen
Copy link
Copy Markdown
Contributor

@esezen esezen commented Apr 22, 2026

Two recommendation pods with the same podId but different indexSectionName (e.g. bestsellers targeting both Products and Search Suggestions) were collapsing into a single result set because the internal cache was keyed by podId alone.

useFetchRecommendationPod wrote both recommendationsResults and podsData as { [podId]: ... }. The second API response silently overwrote the first, and every downstream reader (helpers, useActiveSections, useCioAutocomplete, React keys, view tracking) inherited the collision.

  • New getRecommendationPodKey(podId, indexSectionName) helper producing ${podId}::${indexSectionName ?? 'Products'}, threaded through every write and read site.
  • Fixed inverted guard in useSections (if (!podsData)if (podsData)) so the local state actually hydrates.
  • trackRecommendationView now disambiguates on podId + indexSectionName so view events attribute to the correct section.
  • data-cnstrc-section on recommendation containers falls back to indexSectionName when the pod returns zero results.

Breaking change

podsData returned from useCioAutocomplete is now keyed by the composite key instead of bare podId. External consumers reading this map by bare podId will need to update the lookup.

Public types, SDK request shape, and tracking payload are unchanged.

Copilot AI review requested due to automatic review settings April 22, 2026 15:38
@esezen esezen requested a review from a team as a code owner April 22, 2026 15:38
constructor-claude-bedrock[bot]

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown

@constructor-claude-bedrock constructor-claude-bedrock Bot left a comment

Choose a reason for hiding this comment

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

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: ⚠️ Needs Work

Comment thread src/utils/tracking.ts
Comment thread src/hooks/useFetchRecommendationPod.ts
Comment thread spec/hooks/useFetchRecommendationPod.test.tsx
Comment thread spec/Components/CioAutocomplete/CioAutocomplete.test.tsx
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

@esezen esezen left a comment

Choose a reason for hiding this comment

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

Self review

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.

2 participants