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 and the file path 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 and file path.

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 Jan 7, 2021
1 parent 9667eec commit bb507d3
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 10 deletions.
75 changes: 66 additions & 9 deletions web/server/vue-cli/src/views/ReportDetail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
<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"] }},
file path: {{ $router.currentRoute.query["report-filepath"] }})
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 All @@ -18,6 +54,7 @@
:to="{ name: 'reports', query: {
...$router.currentRoute.query,
'report-id': undefined,
'report-filepath': undefined,
...(
reportFilter.reportHash ? {} : { 'report-hash' : undefined }
)
Expand Down Expand Up @@ -85,7 +122,8 @@ export default {
return {
report: null,
treeItem: null,
showComments: true
showComments: true,
reportNotFound: false
};
},
computed: {
Expand All @@ -105,17 +143,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 @@ -128,16 +179,22 @@ export default {
ord: Order.ASC
});
const filePath = this.$router.currentRoute.query["report-filepath"];
const reportFilter = new ReportFilter({
...this.reportFilter,
isUnique: false,
reportHash: [ reportHash ]
reportHash: [ reportHash ],
filePath: [ filePath ]
});
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
4 changes: 3 additions & 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,9 @@
: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,
'report-filepath': reportFilter.isUnique
? `*${item.checkedFile}` : item.checkedFile
}}"
class="file-name"
>
Expand Down

0 comments on commit bb507d3

Please sign in to comment.