Skip to content

Commit

Permalink
Merge pull request #5 from jennypavlova/196113-apmotelerrors-without-…
Browse files Browse the repository at this point in the history
…an-error-type-result-in-error-details-page-crashing

[APM][Otel] Errors without an error type result in error details page crashing
  • Loading branch information
crespocarlos authored Oct 14, 2024
2 parents 3bfc69d + e8dce71 commit cba684f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plug
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useAnyOfApmParams } from '../../../../hooks/use_apm_params';
import { useApmRouter } from '../../../../hooks/use_apm_router';
import { FETCH_STATUS, isPending } from '../../../../hooks/use_fetcher';
import { FETCH_STATUS, isPending, isSuccess } from '../../../../hooks/use_fetcher';
import { useTraceExplorerEnabledSetting } from '../../../../hooks/use_trace_explorer_enabled_setting';
import { APIReturnType } from '../../../../services/rest/create_call_apm_api';
import { TransactionDetailLink } from '../../../shared/links/apm/transaction_detail_link';
Expand Down Expand Up @@ -111,8 +111,7 @@ export function ErrorSampleDetails({
const loadingErrorData = isPending(errorFetchStatus);
const isLoading = loadingErrorSamplesData || loadingErrorData;

const isSucceded =
errorSamplesFetchStatus === FETCH_STATUS.SUCCESS && errorFetchStatus === FETCH_STATUS.SUCCESS;
const isSucceeded = isSuccess(errorSamplesFetchStatus) && isSuccess(errorFetchStatus);

useEffect(() => {
setSampleActivePage(0);
Expand All @@ -137,7 +136,7 @@ export function ErrorSampleDetails({
});
}, [error, transaction, uiActions]);

if (!error && errorSampleIds?.length === 0 && isSucceded) {
if (!error && errorSampleIds?.length === 0 && isSucceeded) {
return (
<EuiEmptyPrompt
title={
Expand All @@ -160,7 +159,7 @@ export function ErrorSampleDetails({
const status = error.http?.response?.status_code;
const environment = error.service.environment;
const serviceVersion = error.service.version;
const isUnhandled = error.error.exception?.[0].handled === false;
const isUnhandled = error.error.exception?.[0]?.handled === false;

const traceExplorerLink = router.link('/traces/explorer/waterfall', {
query: {
Expand Down Expand Up @@ -371,7 +370,7 @@ export function ErrorSampleDetailTabContent({
return isPlaintextException ? (
<PlaintextStacktrace
message={exceptions[0].message}
type={exceptions[0].type}
type={exceptions[0]?.type}
stacktrace={error?.error.stack_trace}
codeLanguage={codeLanguage}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { rangeQuery, kqlQuery } from '@kbn/observability-plugin/server';
import { unflattenKnownApmEventFields } from '@kbn/apm-data-access-plugin/server/utils';
import { castArray } from 'lodash';
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
import { maybe } from '../../../../common/utils/maybe';
import {
Expand Down Expand Up @@ -155,7 +154,10 @@ export async function getErrorSampleDetails({
},
error: {
...errorFromFields.error,
exception: castArray(source?.error.exception ?? errorFromFields?.error.exception),
exception:
(source?.error.exception?.length ?? 0) > 1
? source?.error.exception
: errorFromFields?.error.exception && [errorFromFields.error.exception],
log: source?.error?.log,
},
},
Expand Down

0 comments on commit cba684f

Please sign in to comment.