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

Cannot import saved objects from 6.8.1 to 7.3.0 if the object has filter aggregations #41240

Closed
bhavyarm opened this issue Jul 16, 2019 · 28 comments · Fixed by #41245
Closed
Labels
bug Fixes for quality problems that affect the customer experience Feature:Saved Objects regression Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@bhavyarm
Copy link
Contributor

bhavyarm commented Jul 16, 2019

Kibana version: 7.3.0 BC4

Elasticsearch version: 7.3.0 BC4

Server OS version: darwin_x86_64

Browser version: chrome latest

Browser OS version: OS X

Original install method (e.g. download page, yum, from source, etc.): from staging

Describe the bug: If user tries to import metric viz with filters aggregation from 6.8.1 to 7.2.0 - Kibana fails to do so and logs:

Exception @ migrations730 while trying to migrate query filters! TypeError: Cannot read property 'query' of undefined

Steps to reproduce:

  1. Load sample data from load sample data kibana tutorial for logstash - create logstash-* index pattern https://www.elastic.co/guide/en/kibana/7.3/tutorial-build-dashboard.html#tutorial-load-sample-data
  2. Import the attached json and associate the saved objects - machine_os horizontal_bard_chart response_code with logstash index pattern
  3. Open the dashboard all_the_viz
  4. Metric viz fails to display and logs [esaggs] > Cannot read property 'doc_count' of undefined on screen

Screenshots (if relevant):

Screen Shot 2019-07-16 at 8 28 40 AM

Errors in browser console (if relevant):

commons.bundle.js:3 Uncaught (in promise) TypeError: Cannot read property 'type' of undefined
    at _callee$ (commons.bundle.js:3)
    at tryCatch (vendors.bundle.dll.js:541)
    at Generator.invoke [as _invoke] (vendors.bundle.dll.js:541)
    at Generator.prototype.<computed> [as next] (vendors.bundle.dll.js:541)
    at asyncGeneratorStep (commons.bundle.js:3)
    at _next (commons.bundle.js:3)
    at commons.bundle.js:3
    at new Promise (<anonymous>)
    at commons.bundle.js:3
    at mapPhrases (commons.bundle.js:3)

Provide logs and/or server output (if relevant):

Kibana logs:

log   [12:16:58.112] [info][server][Kibana][http] http server running
  log   [12:22:29.247] [warning] Importing saved objects from a .json file has been deprecated
  log   [12:22:29.428] [warning][migrations] Exception @ migrations730 while trying to migrate query filters! TypeError: Cannot read property 'query' of undefined
  log   [12:22:29.432] [warning][migrations] Exception @ migrations730 while trying to migrate query filters! TypeError: Cannot read property 'query' of undefined

bubbles.json.txt

@bhavyarm bhavyarm added bug Fixes for quality problems that affect the customer experience Feature:Saved Objects Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Jul 16, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@bhavyarm
Copy link
Contributor Author

Not fixed yet.

@bhavyarm
Copy link
Contributor Author

cc @marius-dr

@bhavyarm bhavyarm changed the title Cannot import saved objects from 6.8.1 to 7.3.0 Cannot import saved objects from 6.8.1 to 7.3.0 if the object has filter aggregations Jul 24, 2019
@bhavyarm
Copy link
Contributor Author

Updated the headline as the rest of the saved objects are fine.

@stacey-gammon
Copy link
Contributor

Hm, when I import bubbles.json into 7.3, it seems to work with no errors. I'm not using a snapshot though, I just did git checkout upstream/7.3

checkbug

@bhavyarm
Copy link
Contributor Author

@marius-dr can you please confirm the status of this bug either on BC6 or on today's snapshot please? I was on yesterday's and today's was still building. Cc @LeeDr

@stacey-gammon
Copy link
Contributor

I checked on BC5 and still couldn't repro. :(

@stacey-gammon
Copy link
Contributor

@marius-dr wasn't able to repro that original error either, so I think this can safely be closed. Maybe @bhavyarm you accidentally were running an older version?

@LeeDr
Copy link

LeeDr commented Jul 30, 2019

I reproduced it on 7.3.0 BC6. A couple of things I tried;

  1. If I take the request from the metric_filter visualization and paste it into the Dev Tools it works and I get back a good response. Here's that response;
{
  "took": 52,
  "timed_out": false,
  "_shards": {
    "total": 3,
    "successful": 3,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 14005,
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "2": {
      "buckets": {
        "{\"query_string\":{\"query\":\"machine.os.keyword:\\\"win 8\\\"\"}}": {
          "doc_count": 2838
        }
      }
    }
  },
  "status": 200
}

If I change the query from lucene to KQL, then it works;
image

And the response has changed to;

{
  "took": 24,
  "timed_out": false,
  "_shards": {
    "total": 3,
    "successful": 3,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 14005,
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "2": {
      "buckets": {
        "machine.os.keyword:\"win 8\"": {
          "doc_count": 2838
        }
      }
    }
  },
  "status": 200
}

If I change the filter back to lucene I get this error;
image

So it's strange that when I open the visualization and the filter is using lucence I initially get this error;
image

but after changing it to KQL and back to lucene I get the different error.

@stacey-gammon
Copy link
Contributor

Should this be filed under a new issue? That error seems completely different from the error that showed up when importing the exported json from 6.8 to 7.3.

@LeeDr
Copy link

LeeDr commented Jul 30, 2019

Looks like there were as many as 3 issues in the original description.

  1. [esaggs] > Cannot read property 'doc_count' of undefined on screen (this is the same thing I just reproduced on the metric_filter visualization which uses a filter aggregation).
  2. Exception @ migrations730 while trying to migrate query filters! TypeError: Cannot read property 'query' of undefined I did not reproduce this
  3. commons.bundle.js:3 Uncaught (in promise) TypeError: Cannot read property 'type' of undefined I think this may indicate a problem on another visualization on the dashboard? I focused only on the metric_filter visualization and didn't see this.
  4. [esaggs] > Cannot convert undefined or null to object I got this after I changed the query type on the filter agg from Lucene to KQL and back to Lucene. I think it's part of problem # 1. If I re-open the metric_filter visualization again I get the 'doc_count' of undefined.

@bhavyarm
Copy link
Contributor Author

@LeeDr the same import works fine in 7.2.1

@bhavyarm
Copy link
Contributor Author

This is the exported saved objects for 7.2.1 for the same objects in 7.3.0 bug
(I didn't select yes to Include related objects because that gives an error):
export_7.2.1.ndjson.txt

@bhavyarm
Copy link
Contributor Author

@stacey-gammon @LeeDr just logged another bug: #42343 I don't think its related but just in case.

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch

@stacey-gammon
Copy link
Contributor

stacey-gammon commented Aug 1, 2019

tagging app arch team too because the bug may have been exposed from some of the filtering refactoring. filter.meta can be undefined. I don't think this is anything new from the migration step.

Might have something to do with this PR: https://github.com/elastic/kibana/pull/35544/files though nothing very obvious, though I do see this line filter.meta = filter.meta || {}; which should make that not undefined, but it's only after the mapping functions. I still don't see how that PR would have caused the issue, looks the same logically as the previous iteration, but maybe I'm just not seeing it right away.

@lukeelmers
Copy link
Member

If I change the query from lucene to KQL, then it works;

If I change the filter back to lucene I get this error;

I was able to reproduce this on 7.3 but not master. On master if I toggle from lucene to KQL or vice-versa and hit apply, it will clear my filter entirely. In 7.3, it will clear the filter from the input, but I get "cannot convert undefined or null to object". Then if I save, I get that same error each time I re-open the vis. (But notably, not the doc_count issue which I think must specific to the dataset provided here).

So I think we should split this particular item out into a separate issue (item 4 from @LeeDr's list above), as it doesn't appear related to migrations and seems to just be a 7.3 problem. Haven't tested on earlier versions.

@lizozom Any thoughts on this or why it might be working on master? I think you've merged a few bugfixes related to filters recently.

@LeeDr
Copy link

LeeDr commented Aug 2, 2019

I guess we need to also test if there are problems on 7.x (7.4.0).

@bhavyarm
Copy link
Contributor Author

bhavyarm commented Aug 5, 2019

I will upload 7.x results shortly. Ran into a different problem.

@bhavyarm
Copy link
Contributor Author

bhavyarm commented Aug 5, 2019

Same bug on 7.x @lukeelmers @LeeDr I am on the snapshot from Build #75 (Aug 2, 2019 5:41:00 AM)

Screen Shot 2019-08-05 at 2 56 20 PM

@bhavyarm
Copy link
Contributor Author

bhavyarm commented Aug 6, 2019

@LeeDr I couldn't reproduce this on 7.0.0/7.1.1

@lukeelmers
Copy link
Member

Confirmed on 7.x that I can reproduce the issue based on the steps described above.

Spent awhile looking at this today and came up empty so far. I saw the same things @stacey-gammon noticed -- this originates from FilterManager, specifically map_phrases.js, but it does look like a default filter.meta is set in map_filter.js. However it is set after mapFn is called... which is where the error is coming from.

It seems this area of code was most affected by #35544 -- however the tags in that PR suggest it was merged for 7.2, which wouldn't explain why @bhavyarm is reporting this as working in 7.2 but not 7.3

@lizozom Any ideas on any of these items, since you currently have the most expertise on the FilterManager?

@bhavyarm
Copy link
Contributor Author

bhavyarm commented Aug 7, 2019

@lukeelmers checked on 7.2.1 again and its definitely working. cc @LeeDr Thanks!

@rudolf rudolf added Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc and removed Feature:Saved Objects Team:AppArch Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Aug 8, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@rudolf rudolf added Feature:Saved Objects Team:AppArch Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Aug 8, 2019
@rudolf
Copy link
Contributor

rudolf commented Aug 8, 2019

Ignore me, I was looking at the wrong ticket.

@zzzuzik
Copy link

zzzuzik commented Aug 10, 2019

We bumped our k8s cluster to 7.3 and was hit hard by this issue. All filters were set to Lucene, if we bulk edit exported virtualization to set language to Kuery, after importing them back GUI says KQL but all filters are gone (empty). We cannot downgrade since there are indices already created and ES refuses downgrade.
Any ideas how we can edit our exported visualizations to have both KQL and filters preserved? (more than 100 of them)

@lizozom
Copy link
Contributor

lizozom commented Aug 12, 2019

@stacey-gammon @lukeelmers I debugged the issue, thinking this was a filter_manager issue, because the error is coming from filter manager (map_pharses).

However, the dashboard shouldn't have filters at all (it doesn't have them in 7.2). The problem happens when in 7.3, this dashboard decides it has a filter and then adds a misshaped one to $scope.filters. filter_state_manager picks in up, and calls setFilter and that's where the error in the console log is coming from.

I didn't figure out why the dashboard thought it had a filter though.

Regardless, we should finally TS the filter manager helper functions. :)

@stacey-gammon
Copy link
Contributor

I think this issue is getting too confusing with all the different bugs going on. I split it out into the two ones that are left:

#43188 and
#43189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Saved Objects regression Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants