fix(xo6/tasks): issue with task type and size when accessing backup runs (#9841)

This commit is contained in:
Joris K
2026-05-18 16:06:36 +02:00
committed by GitHub
parent 100f11308a
commit 4e1c8b7188
6 changed files with 18 additions and 44 deletions

View File

@@ -666,7 +666,7 @@ export type XoTask = {
userId?: string
[key: string]: unknown | undefined
}
result: Record<string, unknown>
result?: Record<string, unknown>
start: number
status: 'failure' | 'interrupted' | 'pending' | 'success'
tasks?: XoTask[]

View File

@@ -44,7 +44,7 @@ export function useXoBackupLogsUtils() {
totalSize = (totalSize ?? 0) + nestedSize
}
} else {
if (!('message' in task) || task.message !== 'transfer' || typeof task.result.size !== 'number') {
if (!('message' in task) || task.message !== 'transfer' || typeof task.result?.size !== 'number') {
return totalSize
}

View File

@@ -2,19 +2,19 @@
<UiCard class="card-container">
<UiCardTitle>
{{ t('errors') }}
<UiCounter :value="Array(task.result).length" accent="danger" size="small" variant="primary" />
<UiCounter :value="1" accent="danger" size="small" variant="primary" />
</UiCardTitle>
<div class="content">
<VtsCardRowKeyValue>
<template #key>{{ t('message') }}</template>
<template #value>{{ task.result.message }}</template>
<template v-if="task.result.message" #addons>
<template #value>{{ task.result?.message }}</template>
<template v-if="task.result?.message" #addons>
<VtsCopyButton :value="String(task.result.message)" />
</template>
</VtsCardRowKeyValue>
</div>
<UiLogEntryViewer
v-if="task.result.stack"
v-if="task.result?.stack"
:content="task.result.stack"
:label="t('api-error-details')"
size="small"

View File

@@ -8,11 +8,11 @@
// Make sure to add this file to your tsconfig.json file as an "includes" or "files" entry.
import type {
RouteRecordInfo,
ParamValue,
ParamValueOneOrMore,
ParamValueZeroOrMore,
ParamValueZeroOrOne,
RouteRecordInfo,
} from 'vue-router'
import type { _ExtractParamParserType } from 'vue-router/experimental'
@@ -88,17 +88,6 @@ declare module 'vue-router/auto-routes' {
{ id: ParamValue<false> },
never
>
'/dev/': RouteRecordInfo<'/dev/', '/dev', Record<never, never>, Record<never, never>, never>
'/dev/colors': RouteRecordInfo<'/dev/colors', '/dev/colors', Record<never, never>, Record<never, never>, never>
'/dev/icons/': RouteRecordInfo<'/dev/icons/', '/dev/icons', Record<never, never>, Record<never, never>, never>
'/dev/icons/[name]': RouteRecordInfo<
'/dev/icons/[name]',
'/dev/icons/:name',
{ name: ParamValue<true> },
{ name: ParamValue<false> },
never
>
'/dev/token': RouteRecordInfo<'/dev/token', '/dev/token', Record<never, never>, Record<never, never>, never>
'/host/[id]': RouteRecordInfo<
'/host/[id]',
'/host/:id',
@@ -402,26 +391,6 @@ declare module 'vue-router/auto-routes' {
routes: '/backup/[id]/targets'
views: never
}
'src/pages/dev/index.vue': {
routes: '/dev/'
views: never
}
'src/pages/dev/colors.vue': {
routes: '/dev/colors'
views: never
}
'src/pages/dev/icons/index.vue': {
routes: '/dev/icons/'
views: never
}
'src/pages/dev/icons/[name].vue': {
routes: '/dev/icons/[name]'
views: never
}
'src/pages/dev/token.vue': {
routes: '/dev/token'
views: never
}
'src/pages/host/[id].vue': {
routes:
| '/host/[id]'

View File

@@ -1,13 +1,17 @@
import { useXoTaskCollection } from '@/modules/task/remote-resources/use-xo-task-collection.ts'
import type { XoTask } from '@vates/types'
import { type FrontXoTask, useXoTaskCollection } from '@/modules/task/remote-resources/use-xo-task-collection.ts'
import { watch } from 'vue'
/**
* Normalize a Task error into a JS Error. Keep the original stacktrace
*/
function normalizeError(taskError: Record<string, unknown>) {
function normalizeError(taskError: Record<string, unknown> | undefined, taskId: FrontXoTask['id']) {
const error = new Error()
if (taskError === undefined) {
error.message = `Task ${taskId} failed without error details`
return error
}
if ('message' in taskError) {
error.message = taskError.message as string
}
@@ -26,7 +30,7 @@ function normalizeError(taskError: Record<string, unknown>) {
export function useXoTaskUtils() {
const { useGetTaskById } = useXoTaskCollection()
async function monitorTask<TResult>(taskId: XoTask['id']): Promise<TResult> {
async function monitorTask<TResult>(taskId: FrontXoTask['id']): Promise<TResult> {
const task = useGetTaskById(taskId)
return new Promise((resolve, reject) => {
@@ -46,10 +50,10 @@ export function useXoTaskUtils() {
resolve(task.result as TResult)
} else if (task.status === 'failure') {
cleanup()
reject(normalizeError(task.result))
reject(normalizeError(task.result, taskId))
} else if (task.status !== 'pending') {
cleanup()
reject(normalizeError(task.result))
reject(normalizeError(task.result, taskId))
}
}
},

View File

@@ -25,6 +25,7 @@
> Users must be able to say: "I had this issue, happy to know it's fixed"
- [REST] Fixed ignored parameters in request body due to a tsoa bug (see https://github.com/lukeautry/tsoa/pull/1858) (PR [#9793](https://github.com/vatesfr/xen-orchestra/pull/9793))
- [Tasks] Fixed issue with task without result and backup runs on task size (PR [#9841](https://github.com/vatesfr/xen-orchestra/pull/9841))
- **XO 5**:
- [Job] Error while using vm.set with `cpuMask` in job view (PR [#9823](https://github.com/vatesfr/xen-orchestra/pull/9823))