Add REST tests pinning behavior around _ingest fields #162741

Merged
joegallo opened 6:08pm on October 20, 2026 wanted to merge 148 Ξ” into elastic/elasticsearch main from
underscore-ingest-yaml-coverage
Diff Delta:
148
About 45 Diff Delta/hour
Classified as:  Feature Add

joegallo's Description of Work

Adds a yaml REST test file that pins down how a source field named _ingest, and the document metadata fields next to it (_id, _index, _routing, _version), behave in ingest pipelines today: in Painless ctx lookups and if conditions, processor field paths, the json processor's add_to_root, and mustache templates. Most tests use _simulate; a few index real documents, since simulate doesn't run the mapper or apply metadata to a bulk item.

This is in the spirit of Hyrum's law. Some of this behavior is documented or unit-tested, but a lot of it is an accident of how the code is structured, and someone may depend on it. If a later change breaks one of these tests, that isn't necessarily a bug, but it should be a deliberate, called-out decision. Each test is tagged [DOCUMENTED], [UNIT-TESTED] or [IMPLEMENTATION], and behavior that existing tests already cover isn't repeated.

I wrote these while reviewing #151916, which changes what ctx._ingest means in Painless. All of the tests pass on main. Run against that branch, 11 of the 13 fail, covering things like ctx._ingest == null checks, if conditions on ctx._ingest, the json merge strategy, and _source.-prefixed metadata paths and templates. Whether each of those is an acceptable change is for that PR to decide; this PR just makes the current behavior visible.

1 total changed file
Loading changes...
You’ve completed the full review pass
The diff well is dry.