fix: 4021 logs page additional error information (#4029)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced `SanitizedHtmlRenderer` for improved and secure HTML
content rendering in search results.

- **Enhancements**
- Improved error handling in the application, including updated error
messages with "TraceID" for better tracking.
- Enhanced user experience by allowing users to view additional error
details during search failures.
- Simplified error output by removing detailed error information from
user interfaces.

- **Bug Fixes**
- Adjusted handling of notifications to more accurately reflect error
states, especially for rate limiting scenarios.

- **Chores**
- Modified dependency version for `rudder-sdk-js` to a specific version,
potentially impacting update capabilities.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Bhargav
2024-07-24 13:46:25 +05:30
committed by GitHub
parent 6ca73b465c
commit 427ee1baf1
4 changed files with 214 additions and 76 deletions
+27 -26
View File
@@ -651,6 +651,17 @@
"statuses": "^2.0.1"
}
},
"node_modules/@bundled-es-modules/tough-cookie": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@bundled-es-modules/tough-cookie/-/tough-cookie-0.1.6.tgz",
"integrity": "sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw==",
"dev": true,
"license": "ISC",
"dependencies": {
"@types/tough-cookie": "^4.0.5",
"tough-cookie": "^4.1.4"
}
},
"node_modules/@colors/colors": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
@@ -1862,16 +1873,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/@mswjs/cookies": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@mswjs/cookies/-/cookies-1.1.1.tgz",
"integrity": "sha512-W68qOHEjx1iD+4VjQudlx26CPIoxmIAtK4ZCexU0/UJBG6jYhcuyzKJx+Iw8uhBIGd9eba64XgWVgo20it1qwA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/@mswjs/interceptors": {
"version": "0.29.1",
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.29.1.tgz",
@@ -2636,9 +2637,9 @@
}
},
"node_modules/@types/node": {
"version": "20.14.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz",
"integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==",
"version": "20.14.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz",
"integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~5.26.4"
@@ -3066,9 +3067,9 @@
"license": "ISC"
},
"node_modules/@vitejs/plugin-vue": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.5.tgz",
"integrity": "sha512-LOjm7XeIimLBZyzinBQ6OSm3UBCNVCpLkxGC0oWmm2YPzVZoxMsdvNVimLTBzpAnR9hl/yn1SHGuRfe6/Td9rQ==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.1.0.tgz",
"integrity": "sha512-QMRxARyrdiwi1mj3AW4fLByoHTavreXq0itdEW696EihXglf1MB3D4C2gBvE0jMPH29ZjC3iK8aIaUMLf4EOGA==",
"dev": true,
"license": "MIT",
"engines": {
@@ -6429,9 +6430,9 @@
"license": "MIT"
},
"node_modules/electron-to-chromium": {
"version": "1.4.833",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.833.tgz",
"integrity": "sha512-aVGP9xK70Ysrzip1m5LoJjCp1EDrYzZ7Pg/O3QR1h3PAhmc8SNfSXV3kmmtkg5rNO42EcTYmLX3eFMgqALlGIA==",
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.0.tgz",
"integrity": "sha512-Vb3xHHYnLseK8vlMJQKJYXJ++t4u1/qJ3vykuVrVjvdiOEhYyT1AuP4x03G8EnPmYvYOhe9T+dADTmthjRQMkA==",
"license": "ISC"
},
"node_modules/element-resize-detector": {
@@ -6502,9 +6503,9 @@
}
},
"node_modules/enhanced-resolve": {
"version": "5.17.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz",
"integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==",
"version": "5.17.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz",
"integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==",
"license": "MIT",
"peer": true,
"dependencies": {
@@ -10781,17 +10782,17 @@
"license": "MIT"
},
"node_modules/msw": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/msw/-/msw-2.3.2.tgz",
"integrity": "sha512-vDn6d6a50vxPE+HnaKQfpmZ4SVXlOjF97yD5FJcUT3v2/uZ65qvTYNL25yOmnrfCNWZ4wtAS7EbtXxygMug2Tw==",
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/msw/-/msw-2.3.4.tgz",
"integrity": "sha512-sHMlwrajgmZSA2l1o7qRSe+azm/I+x9lvVVcOxAzi4vCtH8uVPJk1K5BQYDkzGl+tt0RvM9huEXXdeGrgcc79g==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"@bundled-es-modules/cookie": "^2.0.0",
"@bundled-es-modules/statuses": "^1.0.1",
"@bundled-es-modules/tough-cookie": "^0.1.6",
"@inquirer/confirm": "^3.0.0",
"@mswjs/cookies": "^1.1.0",
"@mswjs/interceptors": "^0.29.0",
"@open-draft/until": "^2.1.0",
"@types/cookie": "^0.6.0",
+153 -38
View File
@@ -1016,7 +1016,8 @@ const useLogs = () => {
} catch (e: any) {
// showErrorNotification("Invalid SQL Syntax");
console.log(e);
notificationMsg.value = "An error occurred while constructing the search query.";
notificationMsg.value =
"An error occurred while constructing the search query.";
return "";
}
}
@@ -1045,7 +1046,8 @@ const useLogs = () => {
const parsedSQL: any = fnParsedSQL();
if (searchObj.meta.sqlMode && parsedSQL == undefined) {
searchObj.data.queryResults.error = "Error while search partition. Search query is invalid.";
searchObj.data.queryResults.error =
"Error while search partition. Search query is invalid.";
return;
}
@@ -1318,7 +1320,8 @@ const useLogs = () => {
Math.max(parseInt(currentValue.zo_sql_num, 10), 0),
0
);
partitionDetail.partitionTotal[0] = searchObj.data.queryResults.total;
partitionDetail.partitionTotal[0] =
searchObj.data.queryResults.total;
}
} else {
searchObj.data.queryResults.total =
@@ -1457,7 +1460,7 @@ const useLogs = () => {
isNaN(searchObj.data.datetime.startTime)
) {
const queryParams: any = router.currentRoute.value.query;
let currentPeriod: string = queryParams?.period || "15m";
const currentPeriod: string = queryParams?.period || "15m";
const extractedDate: any = extractTimestamps(currentPeriod);
searchObj.data.datetime.startTime = extractedDate.from;
searchObj.data.datetime.endTime = extractedDate.to;
@@ -1539,11 +1542,11 @@ const useLogs = () => {
searchObj.data.histogramQuery.query.sql_mode = "full";
// searchObj.data.histogramQuery.query.start_time =
// queryReq.query.start_time;
// queryReq.query.start_time;
// searchObj.data.histogramQuery.query.end_time =
// queryReq.query.end_time;
delete searchObj.data.histogramQuery.query.quick_mode;
delete searchObj.data.histogramQuery.query.from;
@@ -1625,7 +1628,7 @@ const useLogs = () => {
searchObj.data.stream.selectedStream.length <= 1 &&
searchObj.data.resultGrid.currentPage == 1)
) {
if(searchObj.data.queryResults.hits.length > 0) {
if (searchObj.data.queryResults.hits.length > 0) {
await getHistogramQueryData(searchObj.data.histogramQuery);
}
refreshPartitionPagination(true);
@@ -1647,7 +1650,11 @@ const useLogs = () => {
if (parsedSQL) {
aggFlag = hasAggregation(parsedSQL?.columns);
}
if (queryReq.query.from == 0 && searchObj.data.queryResults.hits.length > 0 && !aggFlag) {
if (
queryReq.query.from == 0 &&
searchObj.data.queryResults.hits.length > 0 &&
!aggFlag
) {
setTimeout(async () => {
searchObjDebug["pagecountStartTime"] = performance.now();
await getPageCount(queryReq);
@@ -1678,7 +1685,7 @@ const useLogs = () => {
}
} else {
searchObj.loading = false;
if(!notificationMsg.value) {
if (!notificationMsg.value) {
notificationMsg.value = "Search query is empty or invalid.";
}
}
@@ -1692,7 +1699,9 @@ const useLogs = () => {
console.log("=================== getQueryData Debug ===================");
} catch (e: any) {
searchObj.loading = false;
showErrorNotification(notificationMsg.value || "Error occurred during the search operation.");
showErrorNotification(
notificationMsg.value || "Error occurred during the search operation."
);
notificationMsg.value = "";
}
};
@@ -1822,11 +1831,21 @@ const useLogs = () => {
})
.catch((err) => {
searchObj.loading = false;
searchObj.data.errorMsg = "Error while processing search total count request.";
let trace_id = "";
searchObj.data.errorMsg = "Error while processing search request.";
if (err.response != undefined) {
searchObj.data.errorMsg = err.response.data.error;
searchObj.data.errorMsg =
err.response.data.error +
" TraceID:" +
err.response.data?.trace_id;
if (err.response.data.hasOwnProperty("trace_id")) {
trace_id = err.response.data?.trace_id;
}
} else {
searchObj.data.errorMsg = err.message;
searchObj.data.errorMsg = err.message + " TraceID:" + err?.trace_id;
if (err.hasOwnProperty("trace_id")) {
trace_id = err?.trace_id;
}
}
const customMessage = logsErrorMessage(err?.response?.data.code);
@@ -1838,9 +1857,19 @@ const useLogs = () => {
notificationMsg.value = searchObj.data.errorMsg;
if (err?.response?.data?.code == 429) {
notificationMsg.value = err.response.data.message;
searchObj.data.errorMsg = err.response.data.message;
if (err?.request?.status >= 429) {
notificationMsg.value = err?.response?.data?.message;
searchObj.data.errorMsg =
err?.response?.data?.message;
}
if (trace_id) {
searchObj.data.errorMsg +=
" <br><span class='text-subtitle1'>TraceID:" +
trace_id +
"</span>";
notificationMsg.value += " TraceID:" + trace_id;
trace_id = "";
}
reject(false);
});
@@ -2092,11 +2121,24 @@ const useLogs = () => {
})
.catch((err) => {
searchObj.loading = false;
searchObj.data.errorMsg = "Error while processing search request.";
let trace_id = "";
searchObj.data.errorMsg =
typeof err == "string" && err
? err
: "Error while processing histogram request.";
if (err.response != undefined) {
searchObj.data.errorMsg = err.response.data.error;
searchObj.data.errorMsg =
err.response.data.error +
" TraceID:" +
err.response.data?.trace_id;
if (err.response.data.hasOwnProperty("trace_id")) {
trace_id = err.response.data?.trace_id;
}
} else {
searchObj.data.errorMsg = err.message;
searchObj.data.errorMsg = err.message + " TraceID:" + err?.trace_id;
if (err.hasOwnProperty("trace_id")) {
trace_id = err?.trace_id;
}
}
const customMessage = logsErrorMessage(err?.response?.data.code);
@@ -2108,10 +2150,21 @@ const useLogs = () => {
notificationMsg.value = searchObj.data.errorMsg;
if (err?.response?.data?.code == 429) {
notificationMsg.value = err.response.data.message;
searchObj.data.errorMsg = err.response.data.message;
if (err?.request?.status >= 429) {
notificationMsg.value = err?.response?.data?.message;
searchObj.data.errorMsg =
err?.response?.data?.message;
}
if (trace_id) {
searchObj.data.errorMsg +=
" <br><span class='text-subtitle1'>TraceID:" +
trace_id +
"</span>";
notificationMsg.value += " TraceID:" + trace_id;
trace_id = "";
}
reject(false);
});
});
@@ -2194,7 +2247,8 @@ const useLogs = () => {
searchObj.data.queryResults.aggs = res.data.hits;
searchObj.data.queryResults.scan_size = res.data.scan_size;
searchObj.data.queryResults.took += res.data.took;
searchObj.data.queryResults.result_cache_ratio += res.data.result_cache_ratio;
searchObj.data.queryResults.result_cache_ratio +=
res.data.result_cache_ratio;
// if (hasAggregationFlag) {
// searchObj.data.queryResults.total = res.data.total;
// }
@@ -2233,11 +2287,25 @@ const useLogs = () => {
})
.catch((err) => {
searchObj.loadingHistogram = false;
searchObj.data.errorMsg = "Error while processing histogram request.";
let trace_id = "";
searchObj.data.histogram.errorMsg =
typeof err == "string" && err
? err
: "Error while processing histogram request.";
if (err.response != undefined) {
searchObj.data.histogram.errorMsg = err.response.data.error;
searchObj.data.histogram.errorMsg =
err.response.data.error +
" TraceID:" +
err.response.data?.trace_id;
if (err.response.data.hasOwnProperty("trace_id")) {
trace_id = err.response.data?.trace_id;
}
} else {
searchObj.data.histogram.errorMsg = err.message;
searchObj.data.histogram.errorMsg =
err.message + " TraceID:" + err?.trace_id;
if (err.hasOwnProperty("trace_id")) {
trace_id = err?.trace_id;
}
}
const customMessage = logsErrorMessage(err?.response?.data.code);
@@ -2251,9 +2319,21 @@ const useLogs = () => {
notificationMsg.value = searchObj.data.histogram.errorMsg;
if (err?.response?.data?.code == 429) {
notificationMsg.value = err.response.data.message;
searchObj.data.histogram.errorMsg = err.response.data.message;
if (err?.request?.status >= 429) {
notificationMsg.value = err?.response?.data?.message;
searchObj.data.histogram.errorMsg =
err?.response?.data?.message;
searchObj.data.histogram.errorDetail =
err?.response?.data?.error_detail;
}
if (trace_id) {
searchObj.data.histogram.errorMsg +=
" <br><span class='text-subtitle1'>TraceID:" +
trace_id +
"</span>";
notificationMsg.value += " TraceID:" + trace_id;
trace_id = "";
}
reject(false);
@@ -2869,7 +2949,8 @@ const useLogs = () => {
function getHistogramTitle() {
try {
const currentPage = searchObj.data.resultGrid.currentPage - 1 || 0;
const startCount = currentPage * searchObj.meta.resultGrid.rowsPerPage + 1;
const startCount =
currentPage * searchObj.meta.resultGrid.rowsPerPage + 1;
let endCount;
let totalCount = searchObj.data.queryResults.total || 0;
@@ -2903,10 +2984,17 @@ const useLogs = () => {
}
let plusSign: string = "";
if(searchObj.data.queryResults.partitionDetail.partitions.length > 1 && searchObj.meta.showHistogram == false) {
if (
searchObj.data.queryResults.partitionDetail.partitions.length > 1 &&
searchObj.meta.showHistogram == false
) {
plusSign = "+";
}
const scanSizeLabel = (searchObj.data.queryResults.result_cache_ratio !== undefined && searchObj.data.queryResults.result_cache_ratio > 0)? "Delta Scan Size" : "Scan Size";
const scanSizeLabel =
searchObj.data.queryResults.result_cache_ratio !== undefined &&
searchObj.data.queryResults.result_cache_ratio > 0
? "Delta Scan Size"
: "Scan Size";
const title =
"Showing " +
@@ -2918,7 +3006,9 @@ const useLogs = () => {
plusSign +
" events in " +
searchObj.data.queryResults.took +
" ms. (" + scanSizeLabel + ": " +
" ms. (" +
scanSizeLabel +
": " +
formatSizeFromMB(searchObj.data.queryResults.scan_size) +
plusSign +
")";
@@ -3155,10 +3245,21 @@ const useLogs = () => {
// }, 500);
})
.catch((err) => {
let trace_id = "";
searchObj.data.errorMsg = "Error while processing search request.";
if (err.response != undefined) {
searchObj.data.errorMsg = err.response.data.error;
searchObj.data.errorMsg =
err.response.data.error +
" TraceID:" +
err.response.data?.trace_id;
if (err.response.data.hasOwnProperty("trace_id")) {
trace_id = err.response.data?.trace_id;
}
} else {
searchObj.data.errorMsg = err.message;
searchObj.data.errorMsg = err.message + " TraceID:" + err?.trace_id;
if (err.hasOwnProperty("trace_id")) {
trace_id = err?.trace_id;
}
}
const customMessage = logsErrorMessage(err.response.data.code);
@@ -3166,6 +3267,20 @@ const useLogs = () => {
if (customMessage != "") {
searchObj.data.errorMsg = customMessage;
}
if (err?.request?.status >= 429) {
notificationMsg.value = err?.response?.data?.message;
searchObj.data.errorMsg =
err?.response?.data?.message;
}
if (trace_id) {
searchObj.data.errorMsg +=
" <br><span class='text-subtitle1'>TraceID:" +
trace_id +
"</span>";
trace_id = "";
}
})
.finally(() => (searchObj.loading = false));
} catch (e: any) {
@@ -3175,7 +3290,7 @@ const useLogs = () => {
};
const refreshData = () => {
try{
try {
if (
searchObj.meta.refreshInterval > 0 &&
router.currentRoute.value.name == "logs"
@@ -3194,7 +3309,7 @@ const useLogs = () => {
store.dispatch("setRefreshIntervalID", refreshIntervalID);
// only notify if user is in logs page
if(searchObj.meta.logsVisualizeToggle == "logs"){
if (searchObj.meta.logsVisualizeToggle == "logs") {
$q.notify({
message: `Live mode is enabled. Only top ${searchObj.meta.resultGrid.rowsPerPage} results are shown.`,
color: "positive",
+32 -10
View File
@@ -99,7 +99,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"
>
<h5 class="text-center">
<q-icon name="warning" color="warning" size="10rem" /><br />
<q-icon name="warning"
color="warning" size="10rem" /><br />
<div
data-test="logs-search-filter-error-message"
v-html="searchObj.data.filterErrMsg"
@@ -118,10 +119,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
>
Result not found.
</div>
<SanitizedHtmlRenderer
data-test="logs-search-error-message"
:htmlContent="searchObj.data.errorMsg"
/>
<div data-test="logs-search-error-message" v-else>
Error occurred while retrieving search events.
<q-btn
@click="toggleErrorDetails"
size="sm"
data-test="logs-page-result-error-details-btn"
>{{ t("search.histogramErrorBtnLabel") }}</q-btn
><br />
</div>
<span v-if="disableMoreErrorDetails">
<SanitizedHtmlRenderer
data-test="logs-search-detail-error-message"
:htmlContent="searchObj.data.errorMsg"
/>
</span>
<div
data-test="logs-search-error-20003"
v-if="parseInt(searchObj.data.errorCode) == 20003"
@@ -157,7 +170,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
data-test="logs-search-no-stream-selected-text"
class="text-center col-10 q-mx-auto"
>
<q-icon name="info" color="primary" size="md" /> Select a
<q-icon name="info"
color="primary" size="md" /> Select a
stream and press 'Run query' to continue. Additionally, you
can apply additional filters and adjust the date range to
enhance search.
@@ -176,7 +190,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
data-test="logs-search-error-message"
class="text-center q-mx-auto col-10"
>
<q-icon name="info" color="primary" size="md" />
<q-icon name="info"
color="primary" size="md" />
{{ t("search.noRecordFound") }}
</h6>
</div>
@@ -193,7 +208,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
data-test="logs-search-error-message"
class="text-center q-mx-auto col-10"
>
<q-icon name="info" color="primary" size="md" />
<q-icon name="info"
color="primary" size="md" />
{{ t("search.applySearch") }}
</h6>
</div>
@@ -388,12 +404,16 @@ export default defineComponent({
}
}
},
toggleErrorDetails() {
this.disableMoreErrorDetails = !this.disableMoreErrorDetails;
},
},
setup() {
const { t } = useI18n();
const store = useStore();
const router = useRouter();
const $q = useQuasar();
const disableMoreErrorDetails: boolean = ref(false);
let {
searchObj,
getQueryData,
@@ -496,7 +516,8 @@ export default defineComponent({
if (
searchObj.organizationIdetifier !=
store.state.selectedOrganization.identifier && searchObj.loading == false
store.state.selectedOrganization.identifier &&
searchObj.loading == false
) {
loadLogsData();
} else if (!searchObj.loading) updateStreams();
@@ -523,7 +544,7 @@ export default defineComponent({
searchObj.organizationIdetifier =
store.state.selectedOrganization.identifier;
restoreUrlQueryParams();
if(searchObj.loading==false){
if (searchObj.loading == false) {
resetSearchObj();
resetStreamData();
restoreUrlQueryParams();
@@ -1066,6 +1087,7 @@ export default defineComponent({
handleChartApiError,
visualizeErrorData,
streamListUpdated,
disableMoreErrorDetails,
};
},
computed: {
+2 -2
View File
@@ -111,12 +111,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
><br />
<span v-if="disableMoreErrorDetails">
{{ searchObj.data.histogram.errorMsg }}
{{ searchObj.data.histogram.errorDetail }}
</span>
</h6>
<h6 class="text-center" v-else>
{{ searchObj.data.histogram.errorMsg }}
{{ searchObj.data.histogram.errorDetail }}
</h6>
</div>
<q-virtual-scroll
@@ -467,6 +465,7 @@ import EqualIcon from "../../components/icons/EqualIcon.vue";
import NotEqualIcon from "../../components/icons/NotEqualIcon.vue";
import useLogs from "../../composables/useLogs";
import { convertLogData } from "@/utils/logs/convertLogData";
import SanitizedHtmlRenderer from "@/components/SanitizedHtmlRenderer.vue";
export default defineComponent({
name: "SearchResult",
@@ -479,6 +478,7 @@ export default defineComponent({
ChartRenderer: defineAsyncComponent(
() => import("@/components/dashboards/panels/ChartRenderer.vue")
),
SanitizedHtmlRenderer,
},
emits: [
"update:scroll",