Skip to content

Commit

Permalink
[gui] Handle missing report
Browse files Browse the repository at this point in the history
The server will remove reports from the database which have the same
report hash on run update. This can cause problem, when the user saves
the URL which contains a report id which is actually removed from
the database.

For this reason we will save the report hash in the URL and if
no report is found with the report id in the database we will falback
and search the report by report hash.

If the report hash is not in the url or the report can not be found
by the report id or report hash we will display this information to
the user.
  • Loading branch information
csordasmarton committed Dec 15, 2020
1 parent 9667eec commit 6734664
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
69 changes: 61 additions & 8 deletions web/server/vue-cli/src/views/ReportDetail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
<template>
<splitpanes class="default-theme">
<v-container
v-if="reportNotFound"
class="text-center"
fill-height
>
<v-row align="center" justify="center">
<v-col class="error--text" cols="6">
<h1 class="display-2">
404 - Report not found!
</h1>

<v-alert
class="mt-4"
type="error"
dense
outlined
text
>
The report (report ID: {{ $router.currentRoute.query["report-id"] }},
report hash: {{ $router.currentRoute.query["report-hash"] }})
was removed from the database.

<span v-if="!$router.currentRoute.query['report-hash']">
Unfortunatelly your URL parameter was saved from and older version
of CodeChecker and it does not contain a <i>report-hash</i>
parameter to fallback the search for.
</span>
</v-alert>
</v-col>
</v-row>
</v-container>

<splitpanes
v-else
class="default-theme"
>
<pane size="20">
<v-container
fluid
Expand Down Expand Up @@ -85,7 +120,8 @@ export default {
return {
report: null,
treeItem: null,
showComments: true
showComments: true,
reportNotFound: false
};
},
computed: {
Expand All @@ -105,17 +141,30 @@ export default {
methods: {
loadReport(reportId, reportHash) {
if (reportId) {
this.loadReportById(reportId);
this.loadReportById(reportId).catch(() => {
if (reportHash) {
this.loadReportByHash(reportHash);
} else {
this.reportNotFound = true;
}
});
} else if (reportHash) {
this.loadReportByHash(reportHash);
}
},
loadReportById(reportId) {
ccService.getClient().getReport(reportId,
handleThriftError(reportData => {
this.report = reportData;
}));
return new Promise((res, rej) => {
ccService.getClient().getReport(reportId,
handleThriftError(reportData => {
this.report = reportData;
res(true);
}, err => {
console.warn("Failed to get report for ID:", reportId);
console.warn(err);
rej(err);
}));
});
},
loadReportByHash(reportHash) {
Expand All @@ -137,7 +186,11 @@ export default {
ccService.getClient().getRunResults(this.runIds, limit, offset,
[ sortType ], reportFilter, this.cmpData, getDetails,
handleThriftError(reports => {
this.report = reports[0];
if (reports.length) {
this.report = reports[0];
} else {
this.reportNotFound = true;
}
}));
},
Expand Down
2 changes: 1 addition & 1 deletion web/server/vue-cli/src/views/Reports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
:to="{ name: 'report-detail', query: {
...$router.currentRoute.query,
'report-id': item.reportId ? item.reportId : undefined,
'report-hash': item.reportId ? undefined : item.bugHash
'report-hash': item.bugHash
}}"
class="file-name"
>
Expand Down

0 comments on commit 6734664

Please sign in to comment.