Skip to content

Commit b746c39

Browse files
authored
[Automatic Import] Fix UI validation for Integration and Datastream name (#204943)
## Release Note Fixes Integration and Datastream name validation ## Summary #204409 implemented backend validation for integration and datastream names and this PR fixes allowing numbers on backend <img width="858" alt="image" src="https://github.com/user-attachments/assets/8d61305a-eeb8-41d7-8fa0-f0b466fa7528" /> Closes #204935 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
1 parent 223781c commit b746c39

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

x-pack/platform/plugins/shared/integration_assistant/server/integration_builder/build_integration.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,6 @@ describe('isValidName', () => {
292292
expect(isValidName('anotherValidName')).toBe(true);
293293
});
294294

295-
it('should return false for names with numbers', () => {
296-
expect(isValidName('invalid123')).toBe(false);
297-
expect(isValidName('123invalid')).toBe(false);
298-
expect(isValidName('invalid_123')).toBe(false);
299-
});
300-
301295
it('should return false for empty string', () => {
302296
expect(isValidName('')).toBe(false);
303297
});

x-pack/platform/plugins/shared/integration_assistant/server/integration_builder/build_integration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
3636

3737
if (!isValidName(integration.name)) {
3838
throw new Error(
39-
`Invalid integration name: ${integration.name}, Should only contain letters and underscores`
39+
`Invalid integration name: ${integration.name}, Should only contain letters, numbers and underscores`
4040
);
4141
}
4242

@@ -49,7 +49,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
4949
const dataStreamName = dataStream.name;
5050
if (!isValidName(dataStreamName)) {
5151
throw new Error(
52-
`Invalid datastream name: ${dataStreamName}, Should only contain letters and underscores`
52+
`Invalid datastream name: ${dataStreamName}, Should only contain letters, numbers and underscores`
5353
);
5454
}
5555
const specificDataStreamDir = joinPath(dataStreamsDir, dataStreamName);
@@ -77,7 +77,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
7777
return zipBuffer;
7878
}
7979
export function isValidName(input: string): boolean {
80-
const regex = /^[a-zA-Z_]+$/;
80+
const regex = /^[a-zA-Z0-9_]+$/;
8181
return input.length > 0 && regex.test(input);
8282
}
8383
function createDirectories(

0 commit comments

Comments
 (0)