Elasticsearch version (bin/elasticsearch --version): main branch (HEAD: 4560a0c)
Plugins installed: []
JVM version (java -version): bundled with Elasticsearch
OS version (uname -a if on a Unix-like system): tested on Ubuntu (x86_64) and Darwin (arm64)
Description of the problem including expected versus actual behavior:
When fetching a document and using _source to attempt to retrieve field that is undefined on a document, it can result in a json_generation_exception error. From @romseygeek:
at a guess, that path doesn't exist in the document and we've missed a null check somewhere
Steps to reproduce:
If you are using Kibana and running ES from snapshot, make sure to use the correct/buggy ES snapshot:
export ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.1.0/archives/20220118-151627_25dd4a31/manifest.json"
yarn es snapshot
Create a document:
PUT test/_doc/123
{ "foo": true }
Response (success):
{
"_index" : "test",
"_id" : "123",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
Try to get the document, using a source field that doesn't exist:
GET test/_doc/123?_source=bar
Response (error):
{
"error" : {
"root_cause" : [
{
"type" : "exception",
"reason" : "Failed to get id [123] with includes/excludes set"
}
],
"type" : "exception",
"reason" : "Failed to get id [123] with includes/excludes set",
"caused_by" : {
"type" : "json_generation_exception",
"reason" : "No current event to copy"
}
},
"status" : 500
}
Try to search for the document, using a source field that doesn't exist:
GET test/_search
{ "_source": ["bar"] }
Response (success):
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "test",
"_id" : "123",
"_score" : 1.0,
"_source" : { }
}
]
}
}
It appears this bug was introduced in #81970.
CC @nik9000 @romseygeek
Elasticsearch version (
bin/elasticsearch --version): main branch (HEAD: 4560a0c)Plugins installed: []
JVM version (
java -version): bundled with ElasticsearchOS version (
uname -aif on a Unix-like system): tested on Ubuntu (x86_64) and Darwin (arm64)Description of the problem including expected versus actual behavior:
When fetching a document and using
_sourceto attempt to retrieve field that is undefined on a document, it can result in ajson_generation_exceptionerror. From @romseygeek:Steps to reproduce:
If you are using Kibana and running ES from snapshot, make sure to use the correct/buggy ES snapshot:
Create a document:
Response (success):
{ "_index" : "test", "_id" : "123", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1 }Try to get the document, using a source field that doesn't exist:
Response (error):
{ "error" : { "root_cause" : [ { "type" : "exception", "reason" : "Failed to get id [123] with includes/excludes set" } ], "type" : "exception", "reason" : "Failed to get id [123] with includes/excludes set", "caused_by" : { "type" : "json_generation_exception", "reason" : "No current event to copy" } }, "status" : 500 }Try to search for the document, using a source field that doesn't exist:
Response (success):
{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 1, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "test", "_id" : "123", "_score" : 1.0, "_source" : { } } ] } }It appears this bug was introduced in #81970.
CC @nik9000 @romseygeek