Skip to content

fix(search): prevent facet requests from firing with empty query#801

Merged
thostetler merged 1 commit intoadsabs:masterfrom
thostetler:fix/4xx-facet-errors
Feb 17, 2026
Merged

fix(search): prevent facet requests from firing with empty query#801
thostetler merged 1 commit intoadsabs:masterfrom
thostetler:fix/4xx-facet-errors

Conversation

@thostetler
Copy link
Member

Facet API requests were sometimes sent with an empty q parameter,
producing 4xx errors. This was caused by a race condition where
useGetFacetData read latestQuery from the Zustand store before
submitQuery() updated it after the main search response arrived.
latestQuery defaults to q: '', so facets fired requests before the
real query was in place.

  • Added empty-query guard on the enabled flag in useGetFacetData, matching the existing pattern in YearHistogramSlider and OverviewPageContainer
  • Added tests for empty, whitespace-only, and valid query cases

Facet API requests were sometimes sent with an empty q parameter due to
a race condition where useGetFacetData read latestQuery before the main
search response arrived and submitQuery updated the store. Added an
empty-query guard on the enabled flag, matching the existing pattern in
YearHistogramSlider and OverviewPageContainer.
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.8%. Comparing base (968d8a6) to head (c22a2b4).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #801     +/-   ##
========================================
+ Coverage    61.6%   61.8%   +0.3%     
========================================
  Files         312     313      +1     
  Lines       36000   36230    +230     
  Branches     1594    1622     +28     
========================================
+ Hits        22148   22375    +227     
- Misses      13815   13818      +3     
  Partials       37      37             
Files with missing lines Coverage Δ
src/components/SearchFacet/useGetFacetData.ts 77.9% <100.0%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thostetler thostetler marked this pull request as ready for review February 13, 2026 03:30
@thostetler thostetler merged commit d131c2d into adsabs:master Feb 17, 2026
5 checks passed
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