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

Pull Request Overview

  • Opened on October 20, 2026
  • Status Merged
  • Commit count 1 with first commit October 20, 2026

Total Delta

148 Total Diff Delta

Open Days

Open 10 weekdays

Test Delta

147 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
 
0.0 days Authoring 1 commit before pull request opened for review
 
0.0 days Awaiting first review
 
10.0 days Merge to deploy (still awaiting deployment)

Total time for pull request 0.0 business days from first commit authored to merge
Still awaiting deployment

Author avatar

Add REST tests pinning behavior around _ingest fields

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.

Comments Threads Pending Resolution

Resolved Comment Threads

No resolved comments have been left on this PR.