Replace deprecated angular-instantsearch integration#63
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR migrates the application from the third-party ChangesAngular InstantSearch Migration to Custom Compatibility Layer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/providers/logged-in/algolia.service.ts (1)
93-119:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winRetry branch completes too early and swallows errors.
Line 115 completes the observable before the retry
searchSingleIndexresolves, so retry results can be dropped. Also, returningthrowError(err)inside these promise callbacks does not notify this observer.Proposed fix
- }).catch(err => { - - if(err.statusCode == 400) { - this.getKey(true).then(keyData => { + }).catch(err => { + if (err.statusCode === 400) { + this.getKey(true).then(keyData => { const client = algoliasearch(keyData.appId, keyData.securedApiKey, {}); client.searchSingleIndex({ indexName, searchParams: { query: '', ...searchParameters, }, }).then(content => { - - if (content) { - observer.next(content); - } - }).catch(err => { - return throwError(err); - }); - - observer.complete(); - }); + observer.next(content); + observer.complete(); + }).catch(retryErr => { + observer.error(retryErr); + }); + }).catch(keyErr => observer.error(keyErr)); } else { - return throwError(err); + observer.error(err); } });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/providers/logged-in/algolia.service.ts` around lines 93 - 119, The retry branch currently calls observer.complete() immediately and uses return throwError(err) inside promise callbacks which doesn't notify the Observable; change the logic in the catch(err => { ... }) handling so that you only call observer.complete() after client.searchSingleIndex(...).then(...) has resolved and emitted (via observer.next(content)), and on any rejection from getKey or searchSingleIndex call observer.error(err) (not return throwError(err)). Specifically update the code paths around getKey(...).then(...) and client.searchSingleIndex(...).then(...).catch(...) to propagate errors with observer.error and to move observer.complete() into the final resolution of the retry search so results are not dropped.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/compat/instantsearch/highlight.component.ts`:
- Around line 21-23: The getter content in HighlightComponent dereferences
this.hit._highlightResult without guarding this.hit; update the content getter
(the content accessor) to first check that this.hit is defined (or use optional
chaining) before calling getPropertyByPath on this.hit._highlightResult and on
this.hit, e.g. short-circuit to a safe default when this.hit is null/undefined
so getPropertyByPath is only invoked when this.hit exists and attribute is
present.
In `@src/app/compat/instantsearch/instantsearch.component.ts`:
- Line 12: The component currently ignores the `@Input`('index-name') indexName
and dereferences config.searchClient without guarding for null/undefined, which
can throw; update the component to use indexName (fallback to config.indexName
if needed) when constructing the InstantSearch instance and add null checks
before accessing config and config.searchClient (e.g. in ngOnInit or wherever
createInstantSearch is called) so you only call methods on searchClient when
config and config.searchClient are present, and return or no-op with a logged
warning if they are missing.
---
Outside diff comments:
In `@src/app/providers/logged-in/algolia.service.ts`:
- Around line 93-119: The retry branch currently calls observer.complete()
immediately and uses return throwError(err) inside promise callbacks which
doesn't notify the Observable; change the logic in the catch(err => { ... })
handling so that you only call observer.complete() after
client.searchSingleIndex(...).then(...) has resolved and emitted (via
observer.next(content)), and on any rejection from getKey or searchSingleIndex
call observer.error(err) (not return throwError(err)). Specifically update the
code paths around getKey(...).then(...) and
client.searchSingleIndex(...).then(...).catch(...) to propagate errors with
observer.error and to move observer.complete() into the final resolution of the
retry search so results are not dropped.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ede9bfaa-ebb6-421c-a7d1-617973b5f4ea
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (44)
package.jsonsrc/app/compat/instantsearch/base-widget.tssrc/app/compat/instantsearch/highlight.component.tssrc/app/compat/instantsearch/index-widget.component.tssrc/app/compat/instantsearch/index.tssrc/app/compat/instantsearch/infinite-hits.component.tssrc/app/compat/instantsearch/instantsearch.component.tssrc/app/compat/instantsearch/instantsearch.module.tssrc/app/compat/instantsearch/utils.tssrc/app/components/age-refinement-list/age-refinement-list.component.tssrc/app/components/age-refinement-list/age-refinement-list.module.tssrc/app/components/applied-filters/applied-filters.component.spec.tssrc/app/components/applied-filters/applied-filters.component.tssrc/app/components/applied-filters/applied-filters.module.tssrc/app/components/bawes-ais-pagination/bawes-ais-pagination-module.module.tssrc/app/components/bawes-ais-pagination/bawes-ais-pagination.component.tssrc/app/components/candidate-filter/candidate-filter.module.tssrc/app/components/candidate-filter/candidate-filter.tssrc/app/components/current-refinement/current-refinement.component.spec.tssrc/app/components/current-refinement/current-refinement.component.tssrc/app/components/current-refinement/current-refinement.module.tssrc/app/components/date-range-refinement-list/date-range-refinement-list.component.tssrc/app/components/date-range-refinement-list/date-range-refinement-list.module.tssrc/app/components/fulltimer-filter/fulltimer-filter.module.tssrc/app/components/fulltimer-filter/fulltimer-filter.tssrc/app/components/is-facets-search/is-facets-search.component.spec.tssrc/app/components/is-facets-search/is-facets-search.module.tssrc/app/components/is-search-box/is-search-box.component.spec.tssrc/app/components/is-search-box/is-search-box.component.tssrc/app/components/is-search-box/is-search-box.module.tssrc/app/components/range-refinement-list/range-refinement-list.module.tssrc/app/components/range-refinement-list/range-refinement-list.tssrc/app/components/refinement-list/refinement-list.component.htmlsrc/app/components/refinement-list/refinement-list.component.spec.tssrc/app/components/refinement-list/refinement-list.component.tssrc/app/components/refinement-list/refinement-list.module.tssrc/app/pages/logged-in/candidate/candidate-search/candidate-search.module.tssrc/app/pages/logged-in/candidate/candidate-search/candidate-search.page.htmlsrc/app/pages/logged-in/candidate/candidate-search/candidate-search.page.tssrc/app/pages/logged-in/fulltimer/fulltimer-search/fulltimer-search.module.tssrc/app/pages/logged-in/fulltimer/fulltimer-search/fulltimer-search.page.htmlsrc/app/pages/logged-in/fulltimer/fulltimer-search/fulltimer-search.page.tssrc/app/providers/logged-in/algolia.service.tstsconfig.json
Summary
Verification
/claim #32
Summary by CodeRabbit
Release Notes