Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get/mget fails with json_generation_exception error when using source field that doesn't exist #82891

Closed
jportner opened this issue Jan 20, 2022 · 2 comments
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@jportner
Copy link

jportner commented Jan 20, 2022

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

@jportner jportner added >bug needs:triage Requires assignment of a team area label labels Jan 20, 2022
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jan 20, 2022
This reverts commit 4560a0c. It
unexpectedly caused elastic#82891.
elasticsearchmachine pushed a commit that referenced this issue Jan 20, 2022
This reverts commit 4560a0c. It
unexpectedly caused #82891.
@nik9000 nik9000 closed this as completed Jan 24, 2022
@nik9000
Copy link
Member

nik9000 commented Jan 24, 2022

Closed via revert.

@nik9000 nik9000 added :Search Foundations/Mapping Index mappings, including merging and defining field types and removed needs:triage Requires assignment of a team area label labels Jan 24, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jan 24, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@javanna javanna added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

4 participants