Skip to content

[Data view] Fix allow_hidden usage in the request for fields#217628

Merged
kertal merged 7 commits intoelastic:mainfrom
kertal:data-view-hidden-index-fix
Apr 15, 2025
Merged

[Data view] Fix allow_hidden usage in the request for fields#217628
kertal merged 7 commits intoelastic:mainfrom
kertal:data-view-hidden-index-fix

Conversation

@kertal
Copy link
Member

@kertal kertal commented Apr 9, 2025

Summary

This PR fixes the missing allowHidden/allow_hidden usage for data views using the "allow hidden and system indices" functionality. This enables an advanced use case in Discover, allowing you to e.g. look at internal hidden indices like kibana event logs
When using Discover there are 2 requests for fields using 2 different endpoints, one for all fields, one for the fields that actually contain data.

/fields
/fields_for_wildcards

Both use allow_hidden=true for the described case, but /fields ignored this parameter internally. This leads to issues that are resolved with this PR. However we should aim to refactor this very similar endpoints logic, 2 sources of truth here, with lack of unit test coverage (this PR is a start). This can lead to issues in this area, demonstrated by the 2 issues that are fixed.

fixes #217438
fixes #212933

Testing

  • Create a *kibana-event-log-ds-2025* data view with enabling "Allow hidden and system indices" in Discover
    CleanShot 2025-04-15 at 09 41 47

  • In Discover now should everything should work as expected, before there were just unmapped fields in the fieldlist

Checklist

@kertal
Copy link
Member Author

kertal commented Apr 9, 2025

/ci

@kertal kertal self-assigned this Apr 9, 2025
@kertal kertal added Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// Feature:Data Views Data Views code and UI - index patterns before 8.0 release_note:fix labels Apr 9, 2025
@kertal kertal force-pushed the data-view-hidden-index-fix branch from 72207f1 to bd38beb Compare April 9, 2025 13:46
@kertal
Copy link
Member Author

kertal commented Apr 9, 2025

/ci

2 similar comments
@kertal
Copy link
Member Author

kertal commented Apr 9, 2025

/ci

@kertal
Copy link
Member Author

kertal commented Apr 9, 2025

/ci

@kertal kertal force-pushed the data-view-hidden-index-fix branch from 730b3ae to a78912a Compare April 10, 2025 04:29
@kertal
Copy link
Member Author

kertal commented Apr 10, 2025

/ci


jest.mock('./fetcher');

describe('IndexPatternsApiServer - getFieldsForWildcard', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

adding basic test coverage for the actual problem to fix, there could and should be much more in this area, but where to start? So I decided to focus on the actual issue


jest.mock('../../fetcher');

describe('handler', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

there could be much more tests here, but just started with a test to catch the issue

>,
isRollupsEnabled: () => boolean
) => {
export const registerFields = (router: IRouter, isRollupsEnabled: () => boolean) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

a tiny cleanup, removing redundant code

allow_no_indices: allowNoIndex || false,
includeUnmapped,
},
allowHidden,
Copy link
Member Author

Choose a reason for hiding this comment

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

actual fix

includeEmptyFields,
abortSignal,
runtimeMappings,
allowHidden,
Copy link
Member Author

Choose a reason for hiding this comment

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

actual fix

@kertal kertal requested a review from Copilot April 10, 2025 06:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

@kertal kertal changed the title [Data view] Fix hidden index fix propagation Apr 10, 2025
@kertal kertal marked this pull request as ready for review April 10, 2025 10:17
@kertal kertal requested a review from a team as a code owner April 10, 2025 10:17
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @kertal

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thanks for fixing it!

@kertal kertal merged commit c25d627 into elastic:main Apr 15, 2025
10 checks passed
@kertal kertal deleted the data-view-hidden-index-fix branch April 15, 2025 10:11
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16, 8.17, 8.18, 8.x

https://github.com/elastic/kibana/actions/runs/14466876786

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.16 Backport failed because of merge conflicts
8.17 Backport failed because of merge conflicts
8.18 Backport failed because of merge conflicts
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 217628

Questions ?

Please refer to the Backport tool documentation

kertal added a commit to kertal/kibana that referenced this pull request Apr 15, 2025
…#217628)

This PR fixes the missing allowHidden/allow_hidden usage for data views using the "allow hidden and system indices" functionality when creating a data view. There are 2 endpoints being requested in Discover: `/fields` & `/fields_for_wildcards`

Both use `allow_hidden=true`, but `/fields` ignored this parameter internally. This was fixed.

(cherry picked from commit c25d627)

# Conflicts:
#	src/platform/plugins/shared/data_views/server/rest_api_routes/internal/fields.ts
kertal added a commit to kertal/kibana that referenced this pull request Apr 15, 2025
…#217628)

This PR fixes the missing allowHidden/allow_hidden usage for data views using the "allow hidden and system indices" functionality when creating a data view. There are 2 endpoints being requested in Discover: `/fields` & `/fields_for_wildcards`

Both use `allow_hidden=true`, but `/fields` ignored this parameter internally. This was fixed.

(cherry picked from commit c25d627)

# Conflicts:
#	src/platform/plugins/shared/data_views/server/rest_api_routes/internal/fields.ts
kertal added a commit to kertal/kibana that referenced this pull request Apr 15, 2025
…#217628)

This PR fixes the missing allowHidden/allow_hidden usage for data views using the "allow hidden and system indices" functionality when creating a data view. There are 2 endpoints being requested in Discover: `/fields` & `/fields_for_wildcards`

Both use `allow_hidden=true`, but `/fields` ignored this parameter internally. This was fixed.

(cherry picked from commit c25d627)

# Conflicts:
#	src/platform/plugins/shared/data_views/server/rest_api_routes/internal/fields.ts
kertal added a commit that referenced this pull request Apr 15, 2025
…217628) (#218246)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Data view] Fix allow_hidden usage in the request for fields
(#217628)](#217628)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Matthias
Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2025-04-15T10:11:00Z","message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Data
Views","Team:DataDiscovery","backport:prev-major","v9.1.0"],"title":"[Data
view] Fix allow_hidden usage in the request for
fields","number":217628,"url":"https://github.com/elastic/kibana/pull/217628","mergeCommit":{"message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217628","number":217628,"mergeCommit":{"message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4"}}]}]
BACKPORT-->
kertal added a commit that referenced this pull request Apr 15, 2025
…217628) (#218250)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Data view] Fix allow_hidden usage in the request for fields
(#217628)](#217628)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Matthias
Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2025-04-15T10:11:00Z","message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Data
Views","Team:DataDiscovery","backport:prev-major","v9.1.0"],"title":"[Data
view] Fix allow_hidden usage in the request for
fields","number":217628,"url":"https://github.com/elastic/kibana/pull/217628","mergeCommit":{"message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217628","number":217628,"mergeCommit":{"message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4"}}]}]
BACKPORT-->
@mistic
Copy link
Contributor

mistic commented Apr 15, 2025

This PR didn't make it into the latest BC. Updating the labels.

@mistic mistic added v9.0.1 and removed v9.0.0 labels Apr 15, 2025
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 16, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

3 similar comments
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

kertal added a commit that referenced this pull request Apr 22, 2025
…217628) (#218253)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Data view] Fix allow_hidden usage in the request for fields
(#217628)](#217628)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Matthias
Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2025-04-15T10:11:00Z","message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Data
Views","Team:DataDiscovery","backport:prev-major","v9.1.0"],"title":"[Data
view] Fix allow_hidden usage in the request for
fields","number":217628,"url":"https://github.com/elastic/kibana/pull/217628","mergeCommit":{"message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217628","number":217628,"mergeCommit":{"message":"[Data
view] Fix allow_hidden usage in the request for fields (#217628)\n\nThis
PR fixes the missing allowHidden/allow_hidden usage for data views using
the \"allow hidden and system indices\" functionality when creating a
data view. There are 2 endpoints being requested in Discover: `/fields`
& `/fields_for_wildcards`\n\nBoth use `allow_hidden=true`, but `/fields`
ignored this parameter internally. This was
fixed.","sha":"c25d62739e08d114fcdec495924196a6b9a74fc4"}}]}]
BACKPORT-->

Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
@kibanamachine kibanamachine added v8.18.1 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Apr 22, 2025
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:fix Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.18.1 v8.19.0 v9.0.1 v9.1.0

6 participants