admin/plugins: better error message for updates
Massimo Melina committed
Oct 23, 2025 at 23:48 UTC
d2d31916218768c37a86bcf47e2e99cacc496042
3 files changed
+8
-7
admin/src/InstalledPlugins.ts
+3
-2
@@ -9,7 +9,7 @@ import {
9
} from '@mui/icons-material'
10
import {
11
CFG, Html, HTTP_FAILED_DEPENDENCY, md, newObj, prefix, with_, xlate, formatTime, formatDate, replaceStringToReact,
12
- callable, tryJson, useAutoScroll, NBSP
12
+ callable, tryJson, useAutoScroll, NBSP, isPrimitive
13
} from './misc'
14
import { alertDialog, confirmDialog, formDialog, toast } from './dialog'
15
import _ from 'lodash'
@@ -41,7 +41,8 @@ export default function InstalledPlugins({ updates }: { updates?: true }) {
41
})
42
const theme = useTheme()
43
return h(DataTable, {
44
- error: xlate(error, PLUGIN_ERRORS),
44
+ error: isPrimitive(error) ? xlate(error, PLUGIN_ERRORS)
45
+ : _.map(error, (v, k) => `Error ${k} for: ${v.join(', ')}`).join('; '), // complex error for updates
46
rows: list.length ? list : [], // workaround for DataGrid's bug causing 'no rows' message to be not displayed after 'loading' was also used
47
fillFlex: true,
48
initializing,
admin/src/api.ts
+1
-1
@@ -100,7 +100,7 @@ export function useApiList<T=any, S=T>(cmd:string|Falsy, params: Dict={}, { map,
100
if (par === HTTP_UNAUTHORIZED)
101
state.loginRequired = msg[2]?.possible !== false || HTTP_FORBIDDEN
102
else
103
- setError(err2msg(par))
103
+ setError(_.isString(par) || _.isNumber(par) ? err2msg(par) : par)
104
return
105
}
106
if (op === LIST.props)
src/api.plugins.ts
+4
-4
@@ -34,7 +34,7 @@ const apis: ApiHandlers = {
34
async get_plugin_updates({}, ctx) {
35
return new SendListReadable({
36
async doAtStart(list) {
37
- const errs: string[] = []
37
+ const errs: any = {}
38
list.events(ctx, {
39
pluginDownload({ repo, status }) {
40
list.update({ id: findPluginByRepo(repo)?.id }, { downloading: status ?? null })
@@ -60,11 +60,11 @@ const apis: ApiHandlers = {
60
}))
61
} catch (err: any) {
62
if (err.message !== '404') // the plugin is declaring a wrong repo
63
- errs.push(err.code || err.message)
63
+ (errs[err.code || err.message] ||= []).push(repo)
64
}
65
}))
66
- for (const x of _.uniq(errs))
67
- list.error(x)
66
+ if (!_.isEmpty(errs))
67
+ list.error(errs)
68
list.ready()
69
}
70
})