Skip to content

Commit c465502

Browse files
[8.x] [Streams 🌊] Fix fields simulation restricted keys (elastic#210149) (elastic#210169)
# Backport This will backport the following commits from `main` to `8.x`: - [[Streams 🌊] Fix fields simulation restricted keys (elastic#210149)](elastic#210149) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Marco Antonio Ghiani","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-07T11:45:26Z","message":"[Streams 🌊] Fix fields simulation restricted keys (elastic#210149)\n\n## πŸ““ Summary\r\n\r\nFix failing fields simulation on the schema editor. This happened\r\nbecause the strict excessive keys check on the zod validation for the\r\nAPI request caught extra parameters used client-side on the Schema\r\nEditor, removing those properties fixed the issue.","sha":"dde1bec88bc7a797c21d65305c23ab6c1dc6bed6","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","Feature:Streams","v9.1.0","v8.19.0"],"title":"[Streams 🌊] Fix fields simulation restricted keys","number":210149,"url":"https://github.com/elastic/kibana/pull/210149","mergeCommit":{"message":"[Streams 🌊] Fix fields simulation restricted keys (elastic#210149)\n\n## πŸ““ Summary\r\n\r\nFix failing fields simulation on the schema editor. This happened\r\nbecause the strict excessive keys check on the zod validation for the\r\nAPI request caught extra parameters used client-side on the Schema\r\nEditor, removing those properties fixed the issue.","sha":"dde1bec88bc7a797c21d65305c23ab6c1dc6bed6"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210149","number":210149,"mergeCommit":{"message":"[Streams 🌊] Fix fields simulation restricted keys (elastic#210149)\n\n## πŸ““ Summary\r\n\r\nFix failing fields simulation on the schema editor. This happened\r\nbecause the strict excessive keys check on the zod validation for the\r\nAPI request caught extra parameters used client-side on the Schema\r\nEditor, removing those properties fixed the issue.","sha":"dde1bec88bc7a797c21d65305c23ab6c1dc6bed6"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Marco Antonio Ghiani <[email protected]>
1 parent b25012d commit c465502

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

β€Žx-pack/solutions/observability/plugins/streams_app/public/components/schema_editor/flyout/sample_preview_table.tsxβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import React, { useMemo } from 'react';
99
import { css } from '@emotion/react';
1010
import { i18n } from '@kbn/i18n';
1111
import { EuiCallOut } from '@elastic/eui';
12-
import { NamedFieldDefinitionConfig, WiredStreamDefinition } from '@kbn/streams-schema';
12+
import { WiredStreamDefinition } from '@kbn/streams-schema';
1313
import { useKibana } from '../../../hooks/use_kibana';
1414
import { getFormattedError } from '../../../util/errors';
1515
import { useStreamsAppFetch } from '../../../hooks/use_streams_app_fetch';
1616
import { PreviewTable } from '../../preview_table';
1717
import { LoadingPanel } from '../../loading_panel';
18-
import { SchemaField, isSchemaFieldTyped } from '../types';
18+
import { MappedSchemaField, SchemaField, isSchemaFieldTyped } from '../types';
19+
import { convertToFieldDefinitionConfig } from '../utils';
1920

2021
interface SamplePreviewTableProps {
2122
stream: WiredStreamDefinition;
@@ -36,7 +37,7 @@ const SAMPLE_DOCUMENTS_TO_SHOW = 20;
3637
const SamplePreviewTableContent = ({
3738
stream,
3839
nextField,
39-
}: SamplePreviewTableProps & { nextField: NamedFieldDefinitionConfig }) => {
40+
}: SamplePreviewTableProps & { nextField: MappedSchemaField }) => {
4041
const { streamsRepositoryClient } = useKibana().dependencies.start.streams;
4142

4243
const { value, loading, error } = useStreamsAppFetch(
@@ -48,7 +49,9 @@ const SamplePreviewTableContent = ({
4849
id: stream.name,
4950
},
5051
body: {
51-
field_definitions: [nextField],
52+
field_definitions: [
53+
{ ...convertToFieldDefinitionConfig(nextField), name: nextField.name },
54+
],
5255
},
5356
},
5457
});

β€Žx-pack/solutions/observability/plugins/streams_app/public/components/schema_editor/hooks/use_schema_fields.tsβ€Ž

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77

88
import { i18n } from '@kbn/i18n';
99
import { useAbortController } from '@kbn/observability-utils-browser/hooks/use_abort_controller';
10-
import {
11-
FieldDefinitionConfig,
12-
NamedFieldDefinitionConfig,
13-
WiredStreamGetResponse,
14-
} from '@kbn/streams-schema';
10+
import { NamedFieldDefinitionConfig, WiredStreamGetResponse } from '@kbn/streams-schema';
1511
import { isEqual, omit } from 'lodash';
1612
import { useMemo, useCallback } from 'react';
1713
import { useStreamsAppFetch } from '../../../hooks/use_streams_app_fetch';
1814
import { useKibana } from '../../../hooks/use_kibana';
19-
import { MappedSchemaField, SchemaField, isSchemaFieldTyped } from '../types';
15+
import { SchemaField, isSchemaFieldTyped } from '../types';
16+
import { convertToFieldDefinitionConfig } from '../utils';
2017

2118
export const useSchemaFields = ({
2219
definition,
@@ -205,11 +202,6 @@ export const useSchemaFields = ({
205202
};
206203
};
207204

208-
const convertToFieldDefinitionConfig = (field: MappedSchemaField): FieldDefinitionConfig => ({
209-
type: field.type,
210-
...(field.format && field.type === 'date' ? { format: field.format } : {}),
211-
});
212-
213205
const hasChanges = (
214206
field: Partial<NamedFieldDefinitionConfig>,
215207
fieldUpdate: Partial<NamedFieldDefinitionConfig>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { FieldDefinitionConfig } from '@kbn/streams-schema';
9+
import { MappedSchemaField } from './types';
10+
11+
export const convertToFieldDefinitionConfig = (
12+
field: MappedSchemaField
13+
): FieldDefinitionConfig => ({
14+
type: field.type,
15+
...(field.format && field.type === 'date' ? { format: field.format } : {}),
16+
});

0 commit comments

Comments
Β (0)