Skip to content

Commit 0ce4374

Browse files
authored
[Uptime] Fix broken overview page when no summary data present (#81952) (#82021)
Fixes #81950 by not assuming the summary is present in a bucket with partial check info
1 parent 96bcedf commit 0ce4374

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export const fullyMatchingIds = (queryResult: any, statusFilter?: string): Monit
3838

3939
for (const locBucket of monBucket.location.buckets) {
4040
const latest = locBucket.summaries.latest.hits.hits[0];
41+
// It is possible for no latest summary to exist in this bucket if only partial
42+
// non-summary docs exist
43+
if (!latest) {
44+
continue;
45+
}
46+
4147
const latestStillMatching = locBucket.latest_matching.top.hits.hits[0];
4248
// If the most recent document still matches the most recent document matching the current filters
4349
// we can include this in the result

x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ export default function ({ getService }: FtrProviderContext) {
2424
before('load heartbeat data', () => getService('esArchiver').load('uptime/blank'));
2525
after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank'));
2626

27+
// In this case we don't actually have any monitors to display
28+
// but the query should still return successfully. This has
29+
// caused bugs in the past because a bucket of monitor data
30+
// was available and the query code assumed at least one
31+
// event would be a summary for each monitor.
32+
// See https://github.com/elastic/kibana/issues/81950
33+
describe('checks with no summaries', async () => {
34+
const testMonitorId = 'scope-test-id';
35+
before(async () => {
36+
const es = getService('legacyEs');
37+
dateRangeStart = new Date().toISOString();
38+
await makeChecksWithStatus(es, testMonitorId, 1, numIps, 1, {}, 'up', (d) => {
39+
delete d.summary;
40+
return d;
41+
});
42+
});
43+
44+
it('should return no monitors and have no errors', async () => {
45+
const url = getBaseUrl(dateRangeStart, new Date().toISOString());
46+
const apiResponse = await supertest.get(url);
47+
expect(apiResponse.status).to.equal(200);
48+
});
49+
});
50+
2751
describe('query document scoping with mismatched check statuses', async () => {
2852
let checks: any[] = [];
2953
let nonSummaryIp: string | null = null;

0 commit comments

Comments
 (0)