Skip to content

Apply the page feedback mapping to an index that already exists - #5030

Merged
reakaleek merged 13 commits into
mainfrom
fix-feedback-checkboxes-aec656b1
Nov 24, 2026
Merged

reakaleek merged 13 commits into
mainfrom
fix-feedback-checkboxes-aec656b1

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Page feedback reasons are now indexed on an index created before the field existed. The ingest channel's bootstrap puts the current mapping on page-feedback-v1-{env} instead of relying on a template that only applies to new indices.

Affects: Docs API

Prompt summary: Checked reasons in the page feedback widget did not show up in Elasticsearch on staging, while edge worked. The ask was to find out why and fix it so a stale index cannot hide a field again.

Why

The index has a fixed name, and its templates apply only when the index is created. page-feedback-v1-staging was created under #3705, when the field was reason. #4054 renamed it to reasons. The mapping sets dynamic: false, so on staging reasons is stored in _source but never indexed. Search, filters and ES|QL cannot see it. The widget, the API and the bulk request all send reasons correctly.

What

Bootstrap repairs an existing index

The channel's bootstrap strategy gains a third step after the two template steps. ExistingIndexMappingStep sends PUT page-feedback-v1-{env}/_mapping with the current mapping. Running it again changes nothing. A missing index is fine, because the templates apply on the first write.

A rejected mapping stops the deploy

The step follows the channel's bootstrap method, like the built-in steps. A mapping Elasticsearch rejects, such as a type change, fails startup in staging, edge and prod. In dev the step logs the status and the response, and startup continues. A transport failure is logged as one, with its exception. An update that Elasticsearch accepts but not every node acknowledges in time does not stop startup; the step warns about the possible indexing gap. A breaking change then shows up at deploy time and not as silently unindexed data.

One place builds the channel

PageFeedbackIndex.CreateChannel composes the strategy. The service registration, the bootstrap tests and the gateway write tests all use it, and a gateway test pins the bulk target and the document id. PageFeedbackBootstrapService is unchanged.

The limits are written down

docs/development/page-feedback.md now says that an added field is applied in place and that an incompatible change needs a new index name. It lists the manage index privilege the update needs, and names the _update_by_query call that indexes documents written before a field reached the mapping.

Verify

dotnet test --project tests/Elastic.Documentation.Api.Tests --treenode-filter "/*/*/PageFeedbackBootstrapTests/*"

With ExistingIndexMappingStep removed from the strategy, StartAsync_IndexExists_PutsCurrentMappingOnIt and StartAsync_MappingRejectedInStaging_FailsStartup fail. With the step moved before the template steps, StartAsync_IndexExists_InstallsTemplatesBeforeTheMapping fails.

Risk: This runs on every API start in staging, edge and prod, and a rejected mapping now stops startup there. The request needs the manage index privilege on page-feedback-v1-{env}, so a deployed key without it gets a 403 and the API does not start. Confirm the keys before rollout. The fix also does not repair data. Staging needs a one-time repair by a person after the deploy, because the existing documents stay unindexed for reasons until then:

PUT page-feedback-v1-staging/_mapping
{ "properties": { "reasons": { "type": "keyword" } } }

POST page-feedback-v1-staging/_update_by_query?conflicts=proceed

Out of scope: The step belongs in Elastic.Ingest.Elasticsearch as a built-in bootstrap step, and a TODO marks it for removal once upstream ships one. page-feedback-v1-dev and any prod index are not checked here. Run GET page-feedback-v1-<env>/_mapping on each and confirm reasons is there.

🤖 Generated with Claude Code

An index created before a field was added keeps its old mapping, because templates only apply when an index is created. `page-feedback-v1-staging` was created before `reasons` replaced `reason`, so with `dynamic: false` its `reasons` were stored but never indexed. Startup now puts the current mapping on the existing index.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 24, 2026 09:32
@reakaleek reakaleek added the bug label Nov 24, 2026
@reakaleek
reakaleek requested a review from theletterf November 24, 2026 09:32
The mapping update ran as a raw request beside the ingest channel's bootstrap. It is now an `IBootstrapStep` in the channel's own bootstrap strategy, after the template steps, so the channel handles its failure mode and `PageFeedbackBootstrapService` is unchanged from `main`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

reakaleek and others added 8 commits November 24, 2026 11:20
The provisioning guide told operators to bump the index version for any mapping change, which contradicted the new in-place update of added fields. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`PUT <index>/_mapping` needs the `manage` index privilege, which the guide did not list. A key without it gets a 403 and stops startup outside `dev`. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A missing index is only safe when the templates are already current, because the first write creates the index from them. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
In `dev` the step returned `false` without a trace, and the service then warned that template bootstrap failed even when both templates were installed. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The gateway tests built the channel with the old implicit strategy, so the explicit strategy was only exercised at startup. A new test pins the bulk target and the document id. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The guide repeated the startup failure rule three times and the additive-only rule twice. Simplify pass.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The channel is now built in `PageFeedbackIndex.CreateChannel`. Simplify pass.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The order test already pins the method and path of the mapping request. Simplify pass.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
reakaleek and others added 3 commits November 24, 2026 14:12
The test counted only requests to the expected path, so a second mapping request to another index would have passed. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A connection or TLS failure has no HTTP status, and the warning called it an Elasticsearch rejection without the exception. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Elasticsearch answers 200 with `"acknowledged": false` when not every node confirms the update before the timeout. The update still applies and startup continues, but documents written in that window miss the added fields in the index, so the step now says so. Raised in review by Libra.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
// The update is applied either way; only the wait for every node to confirm it timed out.
if (IsUnacknowledged(response.Body))
logger.LogWarning(
"Not every node acknowledged the mapping update for {IndexName} in time. Documents written before they do are stored without the added fields indexed; run _update_by_query on the index to index them",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

An acknowledgement timeout doesn't mean any page-feedback writes missed the new mapping. If only a node that doesn't handle those writes was slow to acknowledge, this warning still tells operators to rewrite the whole index with _update_by_query. Say that writes may have been affected, and recommend a backfill only after the mapping has propagated and an indexing gap is confirmed.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

@reakaleek
reakaleek merged commit 7a08a7b into main Nov 24, 2026
44 checks passed
@reakaleek
reakaleek deleted the fix-feedback-checkboxes-aec656b1 branch November 24, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant