Skip to content

Commit

Permalink
[Index Management] Restrict dot-prefixed index patterns in template f…
Browse files Browse the repository at this point in the history
…orm (#193196)

Closes #190251

## Summary

This PR adds validation that restricts creating a template with a
dot-prefixed index pattern.

<img width="1194" alt="Screenshot 2024-09-18 at 10 49 47"
src="https://github.com/user-attachments/assets/f24c3e29-7db0-46fc-97de-52d4654073de">

Note: I tried adding tests for this validation
[here](https://github.com/elastic/kibana/blob/6a3adf73dacaeda073674ac4a10e8a2597e67739/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx#L163),
but it didn't work because the index pattern field is mocked in the
tests and errors are not triggered from invalid values.
  • Loading branch information
ElenaStoeva authored Sep 18, 2024
1 parent 78b21cd commit 38d6143
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ export const schemas: Record<string, FormSchema> = {
type: VALIDATION_TYPES.ARRAY_ITEM,
isBlocking: false,
},
{
validator: startsWithField({
char: '.',
message: i18n.translate(
'xpack.idxMgmt.templateValidation.indexPatternDotPrefixedError',
{
defaultMessage: 'Index patterns cannot match dot-prefixed indices.',
}
),
}),
type: VALIDATION_TYPES.ARRAY_ITEM,
},
],
},
doCreateDataStream: {
Expand Down

0 comments on commit 38d6143

Please sign in to comment.