Skip to content

Commit 992e4a8

Browse files
fix: πŸ› correctly create error on no_matching_indices (#61257) (#62755)
* fix: πŸ› correctly create error on no_matching_indices * feat: 🎸 improve error type checking Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent a83455c commit 992e4a8

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

β€Žsrc/plugins/data/public/index_patterns/index_patterns/index_patterns_api_client.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class IndexPatternsApiClient {
4545
query,
4646
})
4747
.catch((resp: any) => {
48-
if (resp.body.statusCode === 404 && resp.body.statuscode === 'no_matching_indices') {
48+
if (resp.body.statusCode === 404 && resp.body.attributes?.code === 'no_matching_indices') {
4949
throw new IndexPatternMissingIndices(resp.body.message);
5050
}
5151

β€Žsrc/plugins/data/server/index_patterns/routes.tsβ€Ž

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,22 @@ export function registerRoutes(http: HttpServiceSetup) {
7070
},
7171
});
7272
} catch (error) {
73-
return response.notFound();
73+
if (
74+
typeof error === 'object' &&
75+
!!error?.isBoom &&
76+
!!error?.output?.payload &&
77+
typeof error?.output?.payload === 'object'
78+
) {
79+
const payload = error?.output?.payload;
80+
return response.notFound({
81+
body: {
82+
message: payload.message,
83+
attributes: payload,
84+
},
85+
});
86+
} else {
87+
return response.notFound();
88+
}
7489
}
7590
}
7691
);

0 commit comments

Comments
Β (0)