Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ui/src/utils/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,19 @@ export const notifierPlugin = {
if (error.response.status) {
msg = `${i18n.global.t('message.request.failed')} (${error.response.status})`
}
if (error.message) {
desc = error.message
}
if (error.response.headers && 'x-description' in error.response.headers) {
if (error.response.headers?.['x-description']) {
desc = error.response.headers['x-description']
}
if (desc === '' && error.response.data) {
} else if (error.response.data) {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition check else if (error.response.data) is too broad and will evaluate to true for empty objects or arrays. This could lead to unnecessary processing of the response data block when there's no actual data. Consider using a more specific check like else if (error.response.data && Object.keys(error.response.data).length > 0) or checking for truthy values that actually contain data.

Suggested change
} else if (error.response.data) {
} else if (error.response.data && (typeof error.response.data !== 'object' || Object.keys(error.response.data).length > 0)) {

Copilot uses AI. Check for mistakes.
const responseKey = _.findKey(error.response.data, 'errortext')
if (responseKey) {
desc = error.response.data[responseKey].errortext
} else if (typeof error.response.data === 'string') {
desc = error.response.data
Comment on lines +227 to +228
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String responses should be trimmed before assignment to avoid displaying empty or whitespace-only error messages. Consider using desc = error.response.data.trim() and only assigning if the trimmed result is non-empty.

Copilot uses AI. Check for mistakes.
}
}
if (!desc && error.message) {
desc = error.message
}
}
let countNotify = store.getters.countNotify
countNotify++
Expand Down
6 changes: 1 addition & 5 deletions ui/src/views/image/RegisterOrUploadTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,7 @@ export default {
this.$emit('refresh-data')
this.closeAction()
}).catch(e => {
this.$notification.error({
message: this.$t('message.upload.failed'),
description: `${this.$t('message.upload.template.failed.description')} - ${e}`,
duration: 0
})
this.$notifyError(e)
})
},
fetchCustomHypervisorName () {
Expand Down
Loading