Skip to content

Commit f585818

Browse files
authored
fix: Throw better error message if version parsing fails (#821)
* Throw better error message if version parsing fails. * Cleaner fix. * Update targeted HTTP endpoint. * Add dummy server route for new endpoint.
1 parent 3c37260 commit f585818

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

__tests__/utils/kibana-test-server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export const createKibanaTestServer = async (kibanaVersion: string) => {
3434
server.route('/s/dummy/api/status', (req, res) =>
3535
res.end(JSON.stringify({ version: { number: kibanaVersion } }))
3636
);
37+
server.route('/s/dummy/api/stats', (req, res) =>
38+
res.end(JSON.stringify({ kibana: { version: kibanaVersion } }))
39+
);
3740
// Legacy
3841
server.route(
3942
'/s/dummy/api/synthetics/service/project/monitors',

src/push/kibana_api.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export async function bulkDeleteMonitors(
124124
}
125125

126126
type StatusResponse = {
127-
version: {
128-
number: string;
127+
kibana: {
128+
version: string;
129129
};
130130
};
131131

@@ -135,7 +135,8 @@ export async function getVersion(options: PushOptions) {
135135
method: 'GET',
136136
auth: options.auth,
137137
});
138-
return data.version.number;
138+
139+
return data.kibana.version;
139140
}
140141

141142
export type LegacyAPISchema = {

src/push/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function generateURL(options: PushOptions, operation: Operation) {
6464
const url = removeTrailingSlash(options.url);
6565
switch (operation) {
6666
case 'status':
67-
return `${url}/s/${options.space}/api/status`;
67+
return `${url}/s/${options.space}/api/stats`;
6868
case 'bulk_get':
6969
case 'bulk_update':
7070
case 'bulk_delete':

0 commit comments

Comments
 (0)