Skip to content

[Inspect] Fix indexpattern parsing leading to incomplete index pattern values being displayed#221084

Merged
kertal merged 15 commits intoelastic:mainfrom
kertal:inspect-fix-indexpattern-parsing
Jun 2, 2025
Merged

[Inspect] Fix indexpattern parsing leading to incomplete index pattern values being displayed#221084
kertal merged 15 commits intoelastic:mainfrom
kertal:inspect-fix-indexpattern-parsing

Conversation

@kertal
Copy link
Member

@kertal kertal commented May 21, 2025

Summary

Fixes #187103

This pull request fixes the parsing of index patterns in the [Inspect] feature of Kibana. Previously, certain index pattern strings were not being parsed and displayed correctly in the which was visible in the Inspec feature.

Changes applied

  • Refactored the index pattern parsing logic to better handle complex and edge-case patterns.
  • Added validation checks to ensure malformed index patterns are gracefully handled.
  • Updated related tests to cover additional cases and ensure consistent behavior.

Testing Instructions

  1. Open Discover
  2. In the KQL bar, filter for a specific _index without using wildcards (e.g. _index: logs-2024-06-27)
  3. Open the Inspect panel

Expected behavior:

It would show the "Index Pattern" as logs-2024-06-27. Instead, just previously logs- was displayed, here's a screen of the previous behavior

image

Checklist

@kertal
Copy link
Member Author

kertal commented May 21, 2025

/ci

@kertal kertal self-assigned this May 22, 2025
@kertal
Copy link
Member Author

kertal commented May 22, 2025

/ci

@kertal kertal added backport:version Backport to applied version labels v8.19.0 Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v9.1.0 labels May 23, 2025
@kertal kertal changed the title [Inspect] fix indexpattern parsing May 23, 2025
@kertal kertal marked this pull request as ready for review May 26, 2025 08:45
@kertal kertal requested review from a team as code owners May 26, 2025 08:45
@elasticmachine
Copy link
Contributor

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

@kertal kertal changed the title [Inspect] Fix indexpattern parsing leading to incomplete Index Pattern values being displayed May 26, 2025
@kertal kertal requested a review from Copilot May 26, 2025 12:18
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.

Pull Request Overview

This PR refactors the index-pattern parsing logic in the Inspect panel to correctly capture full index names (including dashes, numbers, periods, etc.), and adds new unit tests to validate various query-string patterns.

  • Updated the regular expression in parseActiveIndexPatternFromQueryString to be more flexible.
  • Added a suite of tests covering quoted, wildcarded, and multiple index patterns.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/platform/plugins/shared/data/common/search/search_source/search_source.ts Replaced old regex with indexNameRegExp and adjusted loop logic to prevent infinite matches.
src/platform/plugins/shared/data/common/search/search_source/search_source.test.ts Introduced parameterized tests for parseActiveIndexPatternFromQueryString.
Comments suppressed due to low confidence (1)

src/platform/plugins/shared/data/common/search/search_source/search_source.test.ts:1620

  • Add a test case for index patterns that include periods (e.g., 'logs-2024.06.27') to ensure the regex captures dots correctly.
describe('parseActiveIndexPatternFromQueryString', () => {
@kertal kertal requested a review from AlexGPlay May 27, 2025 05:48
Copy link
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

LGTM!

@kertal
Copy link
Member Author

kertal commented Jun 2, 2025

@elasticmachine merge upstream

@kertal kertal enabled auto-merge (squash) June 2, 2025 04:06
@kertal kertal merged commit 931e277 into elastic:main Jun 2, 2025
11 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

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

id before after diff
data 402.3KB 402.2KB -68.0B

History

cc @kertal

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 2, 2025
…n values being displayed (elastic#221084)

Fixes the parsing of index patterns in the Inspect feature. Previously, certain index pattern strings were not
being parsed and displayed correctly.

(cherry picked from commit 931e277)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 2, 2025
… pattern values being displayed (#221084) (#222145)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Inspect] Fix indexpattern parsing leading to incomplete index
pattern values being displayed
(#221084)](#221084)

<!--- 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-06-02T05:35:51Z","message":"[Inspect]
Fix indexpattern parsing leading to incomplete index pattern values
being displayed (#221084)\n\nFixes the parsing of index patterns in the
Inspect feature. Previously, certain index pattern strings were
not\nbeing parsed and displayed
correctly.","sha":"931e277e4a25010e3971b5723356e4717a0caf64","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Team:DataDiscovery","backport:version","v9.1.0","v8.19.0"],"title":"[Inspect]
Fix indexpattern parsing leading to incomplete index pattern values
being
displayed","number":221084,"url":"https://github.com/elastic/kibana/pull/221084","mergeCommit":{"message":"[Inspect]
Fix indexpattern parsing leading to incomplete index pattern values
being displayed (#221084)\n\nFixes the parsing of index patterns in the
Inspect feature. Previously, certain index pattern strings were
not\nbeing parsed and displayed
correctly.","sha":"931e277e4a25010e3971b5723356e4717a0caf64"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/221084","number":221084,"mergeCommit":{"message":"[Inspect]
Fix indexpattern parsing leading to incomplete index pattern values
being displayed (#221084)\n\nFixes the parsing of index patterns in the
Inspect feature. Previously, certain index pattern strings were
not\nbeing parsed and displayed
correctly.","sha":"931e277e4a25010e3971b5723356e4717a0caf64"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
zacharyparikh pushed a commit to zacharyparikh/kibana that referenced this pull request Jun 4, 2025
…n values being displayed (elastic#221084)

Fixes the parsing of index patterns in the Inspect feature. Previously, certain index pattern strings were not
being parsed and displayed correctly.
nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
…n values being displayed (elastic#221084)

Fixes the parsing of index patterns in the Inspect feature. Previously, certain index pattern strings were not
being parsed and displayed correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:Discover Discover Application release_note:fix Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.19.0 v9.1.0

6 participants