Skip to content

Conversation

@teresaromero
Copy link
Contributor

@teresaromero teresaromero commented Dec 16, 2025

What does this PR do?

This PR implements validation into kibana tags assets. When a tag is defined inside the tags.yml is duplicated and an asset is created when exporting the dashboard with elastic-package.

Why is it important?

Avoid duplicate tags at kibana UI, as .json assets when is already declared at tags.yml

Checklist

Related issues

{fn: semantic.ValidateIntegrationPolicyTemplates, types: []string{"integration"}},
{fn: semantic.ValidatePipelineTags, types: []string{"integration"}, since: semver.MustParse("3.6.0")},
{fn: semantic.ValidateStaticHandlebarsFiles, types: []string{"integration", "input"}},
{fn: semantic.ValidateKibanaTagDuplicates, types: []string{"integration"}},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsoriano
content packages also have a tags.yml file, so perhaps we should check if inside the file there are duplicates? this is done inside this function now..

regarding the version, i guess this will "break" more than one integration, as for example crowdstrike is having the duplicate tags. should we address this fix at the integration repository and add this validation for all, or add it from 3.6.0 as a breaking change?

Copy link
Member

Choose a reason for hiding this comment

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

content packages also have a tags.yml file, so perhaps we should check if inside the file there are duplicates? this is done inside this function now..

Yes please, let's check this in all cases. We can probably enable this check for all types, if the files don't exist it doesn't do anything, right?

Suggested change
{fn: semantic.ValidateKibanaTagDuplicates, types: []string{"integration"}},
{fn: semantic.ValidateKibanaTagDuplicates},

regarding the version, i guess this will "break" more than one integration, as for example crowdstrike is having the duplicate tags. should we address this fix at the integration repository and add this validation for all, or add it from 3.6.0 as a breaking change?

I think this should to be reviewed in existing integrations, so I would check this in all packages, or at least in all versions where tags.yml is supported (it is supported since 2.10.0), what would be equivalent.

As escape hatch, I would assign it an error code, so it can be skipped if needed.

We would need to check in any case how many packages in the integrations repository are affected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking into the integrations test, as it was expected, mostly all are failing because of the Security Solution exception. Inline with my comment on elastic/elastic-package#3163 (comment)

i am guessing at least all the json corresponding to the security solution tag can be removed (safely)

Copy link
Member

Choose a reason for hiding this comment

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

i am guessing at least all the json corresponding to the security solution tag can be removed (safely)

Yes, but we would also need to remove the references to these ids from the dashboards, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the json and the reference to that id in the dasboards or any other object where they are referenced

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Overall approach LGTM 👍

{fn: semantic.ValidateIntegrationPolicyTemplates, types: []string{"integration"}},
{fn: semantic.ValidatePipelineTags, types: []string{"integration"}, since: semver.MustParse("3.6.0")},
{fn: semantic.ValidateStaticHandlebarsFiles, types: []string{"integration", "input"}},
{fn: semantic.ValidateKibanaTagDuplicates, types: []string{"integration"}},
Copy link
Member

Choose a reason for hiding this comment

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

content packages also have a tags.yml file, so perhaps we should check if inside the file there are duplicates? this is done inside this function now..

Yes please, let's check this in all cases. We can probably enable this check for all types, if the files don't exist it doesn't do anything, right?

Suggested change
{fn: semantic.ValidateKibanaTagDuplicates, types: []string{"integration"}},
{fn: semantic.ValidateKibanaTagDuplicates},

regarding the version, i guess this will "break" more than one integration, as for example crowdstrike is having the duplicate tags. should we address this fix at the integration repository and add this validation for all, or add it from 3.6.0 as a breaking change?

I think this should to be reviewed in existing integrations, so I would check this in all packages, or at least in all versions where tags.yml is supported (it is supported since 2.10.0), what would be equivalent.

As escape hatch, I would assign it an error code, so it can be skipped if needed.

We would need to check in any case how many packages in the integrations repository are affected.

Comment on lines 38 to 42
require.Len(t, errs, 1)
require.Contains(t, errs[0].Error(), "duplicate tag name 'tag1' found in kibana/tags.yml")
require.Len(t, tagMap, 2)
require.Contains(t, tagMap, "tag1")
require.Contains(t, tagMap, "tag2")
Copy link
Member

Choose a reason for hiding this comment

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

Nit. Even on failure it is nice to return as much information as possible, use assert and conditions when the test can continue if the assertion fails.

Suggested change
require.Len(t, errs, 1)
require.Contains(t, errs[0].Error(), "duplicate tag name 'tag1' found in kibana/tags.yml")
require.Len(t, tagMap, 2)
require.Contains(t, tagMap, "tag1")
require.Contains(t, tagMap, "tag2")
if assert.Len(t, errs, 1) {
assert.Contains(t, errs[0].Error(), "duplicate tag name 'tag1' found in kibana/tags.yml")
}
assert.Len(t, tagMap, 2)
assert.Contains(t, tagMap, "tag1")
assert.Contains(t, tagMap, "tag2")

@teresaromero teresaromero changed the title [draft] validate kibana tags duplicates Validate kibana tags duplicates Dec 17, 2025
@teresaromero teresaromero marked this pull request as ready for review December 17, 2025 09:26
@teresaromero teresaromero requested a review from a team as a code owner December 17, 2025 09:26
@teresaromero
Copy link
Contributor Author

test integrations

@elastic-vault-github-plugin-prod

Created or updated PR in integrations repository to test this version. Check elastic/integrations#16597

jsoriano
jsoriano previously approved these changes Dec 18, 2025
mrodm
mrodm previously approved these changes Dec 22, 2025
| [SVR00004] | Visualization by value |
| [SVR00005] | Minimum Kibana version |
| [SVR00006] | Processor tag is required |
| [SVR00007] | Kibana tag is duplicate |
Copy link
Contributor

Choose a reason for hiding this comment

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

There could be some conflicts with this other PR that is also adding the same validation code errors: #1038

https://github.com/elastic/package-spec/pull/1038/files#diff-d8846111760decbd765dc97b91c095ed8264c3f87d42449304e4735930437d1fR25-R26

@elasticmachine
Copy link

💚 Build Succeeded

History

@teresaromero teresaromero merged commit 10653e8 into elastic:main Jan 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Change Proposal] Add validation to avoid duplicate tags

4 participants