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

[Data plugin] Wrong caching for Index pattern fields #87116

Merged
merged 4 commits into from
Jan 5, 2021

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Jan 4, 2021

Closes: #84666

Summary

[Data plugin] Wrong caching for Index pattern fields. Index pattern cache should be local instance, not global

@@ -46,7 +46,6 @@ import { IndexPatternMissingIndices } from '../lib';
import { findByTitle } from '../utils';
import { DuplicateIndexPatternError } from '../errors';

const indexPatternCache = createIndexPatternCache();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattkime @ppisljar it looks like an issue while unifying client/server code.

This approach unacceptable for server side code. indexPatternCache variable should not declared as instance variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also I think it should be backported into 7.10, 7.11 as a security issue.

@alexwizp alexwizp self-assigned this Jan 4, 2021
@alexwizp alexwizp added v7.12.0 v8.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure release_note:skip Skip the PR/issue when compiling release notes Feature:Data Views Data Views code and UI - index patterns before 8.0 labels Jan 4, 2021
@alexwizp alexwizp marked this pull request as ready for review January 4, 2021 10:21
@alexwizp alexwizp requested a review from a team as a code owner January 4, 2021 10:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@@ -262,44 +262,6 @@ export default function ({ getService }: FtrProviderContext) {
expect(response3.body.index_pattern.typeMeta).to.eql({ foo: 'baz' });
});

it('can update index_pattern fields', async () => {
Copy link
Contributor Author

@alexwizp alexwizp Jan 4, 2021

Choose a reason for hiding this comment

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

have no idea how it worked before but if I'm not wrong users should not be able to change field name/type.

Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

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

Approved pending passing tests and more accurate description - 'Index pattern cache should be local instance, not global'

@alexwizp
Copy link
Contributor Author

alexwizp commented Jan 4, 2021

@mattkime could you please help me with understanding our indexPatterns API.
Please see my example with sending 2 queries.

# First query create a new indexpattern with 2 fields: foo, bar. 

const response = await supertest.post('/api/index_patterns/index_pattern').send({
        index_pattern: {
          title,
          fields: {
            foo: {
              name: 'foo',
              type: 'string',
            },
            bar: {
              name: 'bar',
              type: 'number',
              count: 123,
              script: '',
              esTypes: ['test-type'],
              scripted: true,
            },
          },
        },
      });

in response I see that index was successfully created with 2 fields.

Next query just a getting an indexPattern by id from step 1;

   const response1 = await supertest
        .get('/api/index_patterns/index_pattern/' + response.body.index_pattern.id)
        .send();

I expect to see 2 fields like in response from step 1. But I see only one:
image

What is the correct behavior? I honestly think these are just poorly written integration tests cause user should not be able somehow to modify fields (except scripted fields).

@mattkime
Copy link
Contributor

mattkime commented Jan 4, 2021

@alexwizp You are correct - the user can't add fields aside from scripted fields.

Its valid to ignore the non scripted fields.

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Nice catch @alexwizp, LGTM

@alexwizp
Copy link
Contributor Author

alexwizp commented Jan 5, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Distributable file count

id before after diff
default 47252 48012 +760

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 1003.4KB 1003.5KB +111.0B

History

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

@alexwizp alexwizp merged commit 7ed089c into elastic:master Jan 5, 2021
alexwizp added a commit to alexwizp/kibana that referenced this pull request Jan 5, 2021
* [Data plugin] Wrong caching for Index pattern fields

Closes: elastic#84666

* remove can update index_pattern fields test

* fix tests

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
alexwizp added a commit to alexwizp/kibana that referenced this pull request Jan 5, 2021
* [Data plugin] Wrong caching for Index pattern fields

Closes: elastic#84666

* remove can update index_pattern fields test

* fix tests

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
alexwizp added a commit that referenced this pull request Jan 6, 2021
* [Data plugin] Wrong caching for Index pattern fields

Closes: #84666

* remove can update index_pattern fields test

* fix tests

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
alexwizp added a commit that referenced this pull request Jan 6, 2021
* [Data plugin] Wrong caching for Index pattern fields

Closes: #84666

* remove can update index_pattern fields test

* fix tests

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Data Views Data Views code and UI - index patterns before 8.0 release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Data plugin] Wrong caching for Index pattern fields
5 participants