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

Fix SO query for searching across spaces #83025

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

legrego
Copy link
Member

@legrego legrego commented Nov 10, 2020

Summary

This is a quick followup to #82863.

The original implementation did not construct the query properly when a multi-namespace saved object was being searched via the namespaces=* option.

This also updates the test suite to be more assertive about the expected query to prevent bugs like this from slipping by again.

cc @jgowdyelastic

@legrego legrego added Feature:Saved Objects v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.11 labels Nov 10, 2020
@legrego legrego requested a review from a team as a code owner November 10, 2020 01:21
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Comment on lines -87 to +93
must: [{ term: { type } }, namespacesFilterClause],
must,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, overlooked that too. So we were using [{ term: { type } }, {}] in bool.must?

  • What was the exact consequences?
  • I thought you added a FTR test in the initial PR. Why wasn't this catched by it? Should we add a new one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what was happening. The consequence was a query parse exception:

{
  "name": "ResponseError",
  "meta": {
    "body": {
      "error": {
        "root_cause": [
          {
            "type": "x_content_parse_exception",
            "reason": "[1:120] [bool] failed to parse field [must]"
          }
        ],
        "type": "x_content_parse_exception",
        "reason": "[1:120] [bool] failed to parse field [filter]",
        "caused_by": {
          "type": "x_content_parse_exception",
          "reason": "[1:120] [bool] failed to parse field [should]",
          "caused_by": {
            "type": "x_content_parse_exception",
            "reason": "[1:120] [bool] failed to parse field [must]",
            "caused_by": {
              "type": "illegal_argument_exception",
              "reason": "query malformed, empty clause found at [1:120]"
            }
          }
        }
      },
      "status": 400
    },
    "statusCode": 400,
    "headers": {
      "content-type": "application/json; charset=UTF-8",
      "content-length": "541"
    },
    "meta": {
      "context": null,
      "request": {
        "params": {
          "method": "POST",
          "path": "/.kibana/_search",
          "body": "{\"seq_no_primary_term\":true,\"query\":{\"bool\":{\"filter\":[{\"bool\":{\"should\":[{\"bool\":{\"must\":[{\"term\":{\"type\":\"ml-job\"}},{}],\"must_not\":[{\"exists\":{\"field\":\"namespace\"}}]}}],\"minimum_should_match\":1}}]}}}",
          "querystring": "size=1&from=0&rest_total_hits_as_int=true",
          "headers": {
            "user-agent": "elasticsearch-js/7.10.0-rc.1 (darwin 19.6.0-x64; Node.js v10.22.1)",
            "x-elastic-product-origin": "kibana",
            "content-type": "application/json",
            "content-length": "201"
          },
          "timeout": 30000
        },
        "options": {
          "maxRetries": 0,
          "ignore": [
            404
          ]
        },
        "id": 20
      },
      "name": "elasticsearch-js",
      "connection": {
        "url": "http://localhost:9200/",
        "id": "http://localhost:9200/",
        "headers": {},
        "deadCount": 0,
        "resurrectTimeout": 0,
        "_openRequests": 4,
        "status": "alive",
        "roles": {
          "master": true,
          "data": true,
          "ingest": true,
          "ml": false
        }
      },
      "attempts": 0,
      "aborted": false
    }
  },
  "isBoom": true,
  "isServer": false,
  "data": null,
  "output": {
    "statusCode": 400,
    "payload": {
      "message": "[1:120] [bool] failed to parse field [filter]: x_content_parse_exception",
      "statusCode": 400,
      "error": "Bad Request"
    },
    "headers": {}
  }
}

I thought you added a FTR test in the initial PR. Why wasn't this catched by it? Should we add a new one?

The FTR test verified single namespace types, not multi-namespace types. I can't organically exercise this via the FTR because OSS doesn't have any multi-namespace types, and the default distribution won't allow the * namespace to make its way to the repository.

I'd either have to create an FTR config without spaces or security enabled in the default distribution, or create a test plugin which exposed a route that we could call in test to exercise this path directly. Both options seemed overkill to me, but I'm happy to revisit if you think it'd be worthwhile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 'amazing' that we don't have a SO FTR testsuite in x-pack/test/api_integration/apis tbh... I guess :thisisfine:, ml should introduce 'proper' coverage when they'll leverage the feature.

@legrego legrego merged commit 451e387 into elastic:master Nov 10, 2020
@legrego legrego deleted the chore/fix-search-across-all-spaces branch November 10, 2020 12:37
legrego added a commit to legrego/kibana that referenced this pull request Nov 10, 2020
phillipb added a commit to phillipb/kibana that referenced this pull request Nov 10, 2020
…kibana into bootstrap-node-details-overlay

* 'bootstrap-node-details-overlay' of github.com:phillipb/kibana: (49 commits)
  [Security Solution] Fix DNS Network table query (elastic#82778)
  [Workplace Search] Consolidate groups routes (elastic#83015)
  Adds cloud links to user menu (elastic#82803)
  [Security Solution][Detections] - follow up cleanup on auto refresh rules (elastic#83023)
  [App Search] Added the log retention panel to the Settings page (elastic#82982)
  [Maps] show icon when layer is filtered by time and allow layers to ignore global time range (elastic#83006)
  [DOCS] Consolidates drilldown pages (elastic#82081)
  [Maps] add on-prem EMS config (elastic#82525)
  migrate i18n mixin to KP (elastic#81799)
  [bundle optimization] fix imports of react-use lib (elastic#82847)
  [Discover] Add metric on adding filter (elastic#82961)
  [Lens] Performance refactoring for indexpattern fast lookup and Operation support matrix computation (elastic#82829)
  skip flaky suite (elastic#82804)
  Fix SO query for searching across spaces (elastic#83025)
  renaming built-in alerts to Stack Alerts (elastic#82873)
  [TSVB] Disable using top_hits in pipeline aggregations (elastic#82278)
  [Visualizations] Remove kui usage (elastic#82810)
  [Visualizations] Make the icon buttons labels more descriptive (elastic#82585)
  [Lens] Do not reset formatting when switching between custom ranges and auto histogram (elastic#82694)
  Fix ilm navigation (elastic#81664)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 10, 2020
…na into alerts/stack-alerts-public

* 'alerts/stack-alerts-public' of github.com:gmmorris/kibana:
  [Security Solution] Fix DNS Network table query (elastic#82778)
  [Workplace Search] Consolidate groups routes (elastic#83015)
  Adds cloud links to user menu (elastic#82803)
  [Security Solution][Detections] - follow up cleanup on auto refresh rules (elastic#83023)
  [App Search] Added the log retention panel to the Settings page (elastic#82982)
  [Maps] show icon when layer is filtered by time and allow layers to ignore global time range (elastic#83006)
  [DOCS] Consolidates drilldown pages (elastic#82081)
  [Maps] add on-prem EMS config (elastic#82525)
  migrate i18n mixin to KP (elastic#81799)
  [bundle optimization] fix imports of react-use lib (elastic#82847)
  [Discover] Add metric on adding filter (elastic#82961)
  [Lens] Performance refactoring for indexpattern fast lookup and Operation support matrix computation (elastic#82829)
  skip flaky suite (elastic#82804)
  Fix SO query for searching across spaces (elastic#83025)
  renaming built-in alerts to Stack Alerts (elastic#82873)
  [TSVB] Disable using top_hits in pipeline aggregations (elastic#82278)
  [Visualizations] Remove kui usage (elastic#82810)
  [Visualizations] Make the icon buttons labels more descriptive (elastic#82585)
  [Lens] Do not reset formatting when switching between custom ranges and auto histogram (elastic#82694)
:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Saved Objects release_note:skip Skip the PR/issue when compiling release notes v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants