Skip to content

fix(headless): acknowledge server-side query correction when automaticallyCorrectQuery is disabled#7828

Open
alexprudhomme wants to merge 2 commits into
mainfrom
KIT-5824
Open

fix(headless): acknowledge server-side query correction when automaticallyCorrectQuery is disabled#7828
alexprudhomme wants to merge 2 commits into
mainfrom
KIT-5824

Conversation

@alexprudhomme

@alexprudhomme alexprudhomme commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

KIT-5824

Problem

When a search pipeline overrides automaticallyCorrect to whenNoResults but the headless client has automaticallyCorrectQuery: false, clicking "Show More" on a facet causes facet values to disappear.

Root cause: The server applies the correction and returns results for the corrected query. Headless displays those results and facets. However, because automaticallyCorrectQuery is false, headless never updates state.query.q to the corrected query. When "Show More" triggers a fetchFacetValues request, it uses the original uncorrected query (e.g., "hone") which returns 0 results and empty facets.

Discussion: is this a product bug or client misconfiguration?

Argument for client misconfiguration:

  • The customer configured their pipeline to override automaticallyCorrect to whenNoResults, contradicting their frontend setting of automaticallyCorrectQuery: false. These should agree.
  • If the customer doesn't want auto-correction, they should remove the pipeline override.

Argument for product bug (the approach taken here):

  • Once headless accepts and displays corrected results, it has committed to that state. Forgetting the correction on subsequent requests is inconsistent.
  • Pipeline rules are managed by admins in the Coveo Admin Console; frontend config by developers. It's normal that these are configured independently. The frontend dev may not know the pipeline contradicts their config.
  • automaticallyCorrectQuery: false is documented as controlling whether headless retries a failed query — not whether it acknowledges a correction the server already applied.
  • The fix is minimal (3 lines) and makes headless more resilient to server/client disagreements.

Solution

In processQueryCorrectionsOrContinue, when automaticallyCorrectQuery is false but the server returned a non-empty queryCorrection.correctedQuery, headless now calls processModernDidYouMeanAutoCorrection to update state.query.q to the corrected query. This ensures subsequent requests use the correct query.

@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aac4286

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@coveo/headless Patch
@coveo/quantic Patch
@coveo/headless-react Patch
@coveo/atomic-hosted-page Patch
@coveo/atomic Patch
@coveo/atomic-legacy Patch
@coveo/shopify Patch
@coveo/atomic-react Patch
@coveo/atomic-angular Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svcsnykcoveo

svcsnykcoveo commented Jun 16, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown
@coveo/atomic

npm i https://pkg.pr.new/@coveo/atomic@7828

@coveo/atomic-hosted-page

npm i https://pkg.pr.new/@coveo/atomic-hosted-page@7828

@coveo/atomic-legacy

npm i https://pkg.pr.new/@coveo/atomic-legacy@7828

@coveo/atomic-react

npm i https://pkg.pr.new/@coveo/atomic-react@7828

@coveo/auth

npm i https://pkg.pr.new/@coveo/auth@7828

@coveo/bueno

npm i https://pkg.pr.new/@coveo/bueno@7828

@coveo/create-atomic

npm i https://pkg.pr.new/@coveo/create-atomic@7828

@coveo/create-atomic-component

npm i https://pkg.pr.new/@coveo/create-atomic-component@7828

@coveo/create-atomic-component-project

npm i https://pkg.pr.new/@coveo/create-atomic-component-project@7828

@coveo/create-atomic-result-component

npm i https://pkg.pr.new/@coveo/create-atomic-result-component@7828

@coveo/create-atomic-rollup-plugin

npm i https://pkg.pr.new/@coveo/create-atomic-rollup-plugin@7828

@coveo/headless

npm i https://pkg.pr.new/@coveo/headless@7828

@coveo/headless-react

npm i https://pkg.pr.new/@coveo/headless-react@7828

@coveo/shopify

npm i https://pkg.pr.new/@coveo/shopify@7828

commit: aac4286

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🔗 Scratch Orgs ready to test this PR:

@chromatic-com

chromatic-com Bot commented Jun 16, 2026

Copy link
Copy Markdown

Important

Testing in progress…

🟢 UI Tests: 433 tests unchanged
UI Review: Comparing 433 stories…
Storybook icon Storybook Publish: 433 stories published

@chromatic-com

chromatic-com Bot commented Jun 16, 2026

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 433 tests unchanged
🟢 UI Review: 433 stories published -- no changes
Storybook icon Storybook Publish: 433 stories published

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a headless edge case where the server applies a query correction (e.g., via pipeline override) even though the client has automaticallyCorrectQuery: false. The change makes headless “acknowledge” the server-corrected query so subsequent requests (like facet “Show More”) use the corrected query rather than the original.

Changes:

  • Update search thunk processors to recognize queryCorrection.correctedQuery even when automaticallyCorrectQuery is disabled.
  • Add unit tests covering the new behavior for the main search thunk processor.
  • Add a changeset for @coveo/headless describing the patch.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
packages/headless/src/features/search/search-actions-thunk-processor.ts Adds an early-return path to update state.query.q when the server already applied a correction despite automaticallyCorrectQuery: false.
packages/headless/src/features/search/search-actions-thunk-processor.test.ts Adds coverage for server-applied query correction when automaticallyCorrectQuery is false.
packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.ts Mirrors the same correction-acknowledgement behavior for insight search.
.changeset/fix-server-query-correction.md Publishes the change as a patch for @coveo/headless.

Comment on lines +183 to 191
if (!automaticallyCorrectQuery) {
if (
!isNullOrUndefined(queryCorrection) &&
!isNullOrUndefined(queryCorrection.correctedQuery)
) {
return this.processModernDidYouMeanAutoCorrection(fetched);
}
return null;
}
Comment on lines +120 to 128
if (!automaticallyCorrectQuery) {
if (
!isNullOrUndefined(queryCorrection) &&
!isNullOrUndefined(queryCorrection.correctedQuery)
) {
return this.processNextDidYouMeanAutoCorrection(fetched);
}
return null;
}
import type {Relay} from '@coveo/relay';
import type {Logger} from 'pino';
import {type Mock} from 'vitest';
import type {SearchAPIClient} from '../../api/search/search-api-client.js';
Comment on lines +120 to +125
if (!automaticallyCorrectQuery) {
if (
!isNullOrUndefined(queryCorrection) &&
!isNullOrUndefined(queryCorrection.correctedQuery)
) {
return this.processNextDidYouMeanAutoCorrection(fetched);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants