Skip to content

Commit

Permalink
Merge branch '8.9' into fix/163473-8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 authored Aug 21, 2023
2 parents 9fc470d + 2774922 commit 94cc8d5
Show file tree
Hide file tree
Showing 32 changed files with 640 additions and 248 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": true,
"version": "8.9.1",
"version": "8.9.2",
"branch": "8.9",
"types": "./kibana.d.ts",
"tsdocMetadata": "./build/tsdoc-metadata.json",
Expand Down Expand Up @@ -78,6 +78,7 @@
},
"resolutions": {
"**/@types/node": "16.11.68",
"**/@typescript-eslint/utils": "5.62.0",
"**/chokidar": "^3.5.3",
"**/globule/minimatch": "^3.1.2",
"**/hoist-non-react-statics": "^3.3.2",
Expand All @@ -96,7 +97,7 @@
"@elastic/apm-rum-react": "^1.4.2",
"@elastic/charts": "59.0.0",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.8.0-canary.2",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.9.1-canary.1",
"@elastic/ems-client": "8.4.0",
"@elastic/eui": "82.1.0",
"@elastic/filesaver": "1.1.2",
Expand Down Expand Up @@ -1349,9 +1350,9 @@
"@types/yauzl": "^2.9.1",
"@types/yazl": "^2.4.2",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@typescript-eslint/typescript-estree": "^5.54.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/typescript-estree": "^5.62.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"@yarnpkg/lockfile": "^1.1.0",
"abab": "^2.0.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,8 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
datastreamsILM: `${FLEET_DOCS}data-streams.html#data-streams-ilm`,
datastreamsNamingScheme: `${FLEET_DOCS}data-streams.html#data-streams-naming-scheme`,
datastreamsManualRollover: `${ELASTICSEARCH_DOCS}use-a-data-stream.html#manually-roll-over-a-data-stream`,
datastreamsTSDS: `${ELASTICSEARCH_DOCS}tsds.html`,
datastreamsTSDSMetrics: `${ELASTICSEARCH_DOCS}tsds.html#time-series-metric`,
installElasticAgent: `${FLEET_DOCS}install-fleet-managed-elastic-agent.html`,
installElasticAgentStandalone: `${FLEET_DOCS}install-standalone-elastic-agent.html`,
upgradeElasticAgent: `${FLEET_DOCS}upgrade-elastic-agent.html`,
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ export interface DocLinks {
datastreamsILM: string;
datastreamsNamingScheme: string;
datastreamsManualRollover: string;
datastreamsTSDS: string;
datastreamsTSDSMetrics: string;
installElasticAgent: string;
installElasticAgentStandalone: string;
packageSignatures: string;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data_views/server/rest_api_routes/route_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export type FieldSpecRestResponse = DataViewFieldBaseRestResponse & {
fixedInterval?: string[];
timeZone?: string[];
timeSeriesDimension?: boolean;
timeSeriesMetric?: 'histogram' | 'summary' | 'gauge' | 'counter';
timeSeriesMetric?: 'histogram' | 'summary' | 'gauge' | 'counter' | 'position';
shortDotsEnable?: boolean;
isMapped?: boolean;
parentName?: string;
Expand Down Expand Up @@ -162,6 +162,6 @@ export interface FieldDescriptorRestResponse {
metadata_field?: boolean;
fixedInterval?: string[];
timeZone?: string[];
timeSeriesMetric?: 'histogram' | 'summary' | 'counter' | 'gauge';
timeSeriesMetric?: 'histogram' | 'summary' | 'counter' | 'gauge' | 'position';
timeSeriesDimension?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,8 @@ export class SavedSearchEmbeddable

if (this.abortController) this.abortController.abort();
}

public hasTimeRange() {
return this.getTimeRange() !== undefined;
}
}
1 change: 1 addition & 0 deletions src/plugins/discover/public/embeddable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface SearchOutput extends EmbeddableOutput {

export interface ISearchEmbeddable extends IEmbeddable<SearchInput, SearchOutput> {
getSavedSearch(): SavedSearch;
hasTimeRange(): boolean;
}

export interface SearchEmbeddable extends Embeddable<SearchInput, SearchOutput> {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/discover/public/utils/get_sharing_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('getSharingData', () => {
index.timeFieldName = 'cool-timefield';
const searchSourceMock = createSearchSourceMock({ index });
const { getSearchSource } = await getSharingData(searchSourceMock, {}, services);
expect(getSearchSource()).toMatchInlineSnapshot(`
expect(getSearchSource({})).toMatchInlineSnapshot(`
Object {
"fields": Array [
Object {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('getSharingData', () => {
},
services
);
expect(getSearchSource()).toMatchInlineSnapshot(`
expect(getSearchSource({})).toMatchInlineSnapshot(`
Object {
"index": "the-data-view-id",
"sort": Array [
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('getSharingData', () => {
},
services
);
expect(getSearchSource().fields).toStrictEqual([
expect(getSearchSource({}).fields).toStrictEqual([
{ field: 'cool-timefield', include_unmapped: 'true' },
{ field: 'cool-field-1', include_unmapped: 'true' },
{ field: 'cool-field-2', include_unmapped: 'true' },
Expand Down
43 changes: 25 additions & 18 deletions src/plugins/discover/public/utils/get_sharing_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,35 @@ export async function getSharingData(
const absoluteTimeFilter = data.query.timefilter.timefilter.createFilter(index);
const relativeTimeFilter = data.query.timefilter.timefilter.createRelativeFilter(index);
return {
getSearchSource: (absoluteTime?: boolean): SerializedSearchSourceFields => {
getSearchSource: ({
addGlobalTimeFilter,
absoluteTime,
}: {
addGlobalTimeFilter?: boolean;
absoluteTime?: boolean;
}): SerializedSearchSourceFields => {
const timeFilter = absoluteTime ? absoluteTimeFilter : relativeTimeFilter;
if (addGlobalTimeFilter && timeFilter) {
// remove timeFilter from existing filter
if (Array.isArray(existingFilter)) {
existingFilter = existingFilter.filter(
(current) => !isEqualFilters(current, absoluteTimeFilter)
);
} else if (isEqualFilters(existingFilter, absoluteTimeFilter)) {
existingFilter = undefined;
}

// remove timeFilter from existing filter
if (Array.isArray(existingFilter)) {
existingFilter = existingFilter.filter(
(current) => !isEqualFilters(current, absoluteTimeFilter)
);
} else if (isEqualFilters(existingFilter, absoluteTimeFilter)) {
existingFilter = undefined;
if (existingFilter) {
existingFilter = Array.isArray(existingFilter)
? [timeFilter, ...existingFilter]
: ([timeFilter, existingFilter] as Filter[]);
} else {
existingFilter = timeFilter;
}
}

if (existingFilter && timeFilter) {
searchSource.setField(
'filter',
Array.isArray(existingFilter)
? [timeFilter, ...existingFilter]
: ([timeFilter, existingFilter] as Filter[])
);
} else {
const filter = timeFilter || existingFilter;
searchSource.setField('filter', filter);
if (existingFilter) {
searchSource.setField('filter', existingFilter);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "x-pack",
"version": "8.9.1",
"version": "8.9.2",
"author": "Elastic",
"private": true,
"license": "Elastic-License",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const fetchAnalyticsCollections = async (
): Promise<AnalyticsCollection[]> => {
try {
const collections = await client.asCurrentUser.searchApplication.getBehavioralAnalytics({
name: query,
name: [query],
});

return Object.keys(collections).map((value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const startMlModelDownload = async (

// we're not downloaded yet - let's initiate that...
const putRequest: MlPutTrainedModelRequest = {
// @ts-expect-error @elastic-elasticsearch inference_config can be optional
body: {
input: {
field_names: ['text_field'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,9 @@ export const VisualizationWrapper = ({
executionContext={executionContext}
renderMode="edit"
renderError={(errorMessage?: string | null, error?: ExpressionRenderError | null) => {
const errorsFromRequest = getOriginalRequestErrorMessages(error);
const errorsFromRequest = getOriginalRequestErrorMessages(error || null, core.docLinks);
const visibleErrorMessages = errorsFromRequest.length
? errorsFromRequest
? errorsFromRequest.map((e) => e.longMessage || e.shortMessage)
: errorMessage
? [errorMessage]
: [];
Expand Down Expand Up @@ -829,11 +829,15 @@ export const VisualizationWrapper = ({
</p>

{localState.expandError
? visibleErrorMessages.map((visibleErrorMessage) => (
<p className="eui-textBreakWord" key={visibleErrorMessage}>
{visibleErrorMessage}
</p>
))
? visibleErrorMessages.map((visibleErrorMessage) =>
typeof visibleErrorMessage === 'string' ? (
<p className="eui-textBreakWord" key={visibleErrorMessage}>
{visibleErrorMessage}
</p>
) : (
visibleErrorMessage
)
)
: null}
</>
}
Expand Down
124 changes: 115 additions & 9 deletions x-pack/plugins/lens/public/editor_frame_service/error_helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

import { getOriginalRequestErrorMessages } from './error_helper';
import type { CoreStart } from '@kbn/core/public';

const docLinksMock = { links: { fleet: { datastreamsTSDSMetrics: '' } } } as CoreStart['docLinks'];

const runtimeFieldError = {
stack: 'Error: EsError\n...',
Expand Down Expand Up @@ -163,33 +166,136 @@ const indexpatternAccessError = {
},
};

const tsdbCounterUsedWithWrongOperationError = {
stack:
'Error: EsError: Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
message:
'[layeredXyVis] > [esaggs] > EsError: Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
name: 'Error',
original: {
attributes: {
type: 'status_exception',
reason: 'error while executing search',
caused_by: {
type: 'search_phase_execution_exception',
reason: 'all shards failed',
phase: 'query',
grouped: true,
failed_shards: [
{
shard: 0,
index: 'tsdb_index',
reason: {
type: 'illegal_argument_exception',
reason:
'Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
},
},
],
caused_by: {
type: 'illegal_argument_exception',
reason:
'Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
caused_by: {
type: 'illegal_argument_exception',
reason:
'Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
},
},
},
},
err: {
message:
'status_exception\n\tCaused by:\n\t\tsearch_phase_execution_exception: all shards failed',
statusCode: 400,
attributes: {
type: 'status_exception',
reason: 'error while executing search',
caused_by: {
type: 'search_phase_execution_exception',
reason: 'all shards failed',
phase: 'query',
grouped: true,
failed_shards: [
{
shard: 0,
index: 'tsdb_index',
reason: {
type: 'illegal_argument_exception',
reason:
'Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
},
},
],
caused_by: {
type: 'illegal_argument_exception',
reason:
'Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
caused_by: {
type: 'illegal_argument_exception',
reason:
'Field [bytes_counter] of type [long][counter] is not supported for aggregation [sum]',
},
},
},
},
},
},
};

describe('lens_error_helpers', () => {
describe('getOriginalRequestErrorMessages', () => {
it('should report no errors if not parsable', () => {
expect(getOriginalRequestErrorMessages(null)).toEqual([]);
expect(getOriginalRequestErrorMessages(null, docLinksMock)).toEqual([]);
});

it('should report an error for a runtime field error', () => {
expect(getOriginalRequestErrorMessages(runtimeFieldError)).toEqual([
'Request error: number_format_exception, For input string: "hello" in "emit(Integer.parseInt(\'hello\'))" (Painless script)',
expect(getOriginalRequestErrorMessages(runtimeFieldError, docLinksMock)).toEqual([
expect.objectContaining({
shortMessage:
'Request error: number_format_exception, For input string: "hello" in "emit(Integer.parseInt(\'hello\'))" (Painless script)',
}),
]);
});

it('should report an error for a scripted field error', () => {
expect(getOriginalRequestErrorMessages(scriptedFieldError)).toEqual([
'Request error: aggregation_execution_exception, Unsupported script value [hello], expected a number, date, or boolean in Painless script',
expect(getOriginalRequestErrorMessages(scriptedFieldError, docLinksMock)).toEqual([
expect.objectContaining({
shortMessage:
'Request error: aggregation_execution_exception, Unsupported script value [hello], expected a number, date, or boolean in Painless script',
}),
]);
});

it('should report the original es aggs error for runtime fields for indexpattern not accessible', () => {
expect(getOriginalRequestErrorMessages(indexpatternAccessError as Error)).toEqual([
indexpatternAccessError.message,
expect(
getOriginalRequestErrorMessages(indexpatternAccessError as Error, docLinksMock)
).toEqual([
expect.objectContaining({
shortMessage: indexpatternAccessError.message,
}),
]);
});

it("should report a network custom message when there's a network/connection problem", () => {
expect(getOriginalRequestErrorMessages(networkError as Error)).toEqual([
'Network error, try again later or contact your administrator.',
expect(getOriginalRequestErrorMessages(networkError as Error, docLinksMock)).toEqual([
expect.objectContaining({
shortMessage: 'Network error, try again later or contact your administrator.',
}),
]);
});

it('should report two specific errors in case of an unsupported operation applied to a TSDB counter', () => {
expect(
getOriginalRequestErrorMessages(
tsdbCounterUsedWithWrongOperationError as Error,
docLinksMock
)
).toEqual([
expect.objectContaining({
shortMessage:
'The field [bytes_counter] of Time series type [counter] has been used with the unsupported operation [sum].',
}),
]);
});
});
Expand Down
Loading

0 comments on commit 94cc8d5

Please sign in to comment.