Skip to content

Commit 8cb8c89

Browse files
committed
fix: handle stale enum values when retrying tasks
When retrying a task from history, stale enum values (e.g. a removed model) were sent directly to the server, causing a ValidationException. The error was displayed as a generic unhelpful message. This commit fixes four related issues: - Fix typo in TaskTypeFields.vue that prevented optional enum fields from ever receiving their dropdown options (e.g. model selection in Advanced options was completely broken) - Change "Try again" from history sidebar to load the task into the form instead of auto-submitting, so the user can review and fix stale values before resubmitting - Add a watch in EnumField.vue that clears enum values not matching any available option, preventing stale values from persisting in the form state - Show the server's actual validation error message in the toast notification instead of a generic "Something went wrong" message Closes #400 Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent 6bcd51f commit 8cb8c89

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

src/assistant.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ export async function openAssistantForm({
170170
.catch(error => {
171171
view.loading = false
172172
view.showSyncTaskRunning = false
173-
console.error('Assistant scheduling error', error?.response?.data?.ocs?.data?.message)
174-
showError(t('assistant', 'Assistant error') + ': ' + t('assistant', 'Something went wrong when scheduling the task'))
173+
const serverMessage = error?.response?.data?.ocs?.data?.message
174+
console.error('Assistant scheduling error', serverMessage)
175+
showError(
176+
t('assistant', 'Assistant error') + ': '
177+
+ (serverMessage || t('assistant', 'Something went wrong when scheduling the task')),
178+
)
175179
})
176180
}
177181
modalMountPoint.addEventListener('sync-submit', (data) => {
@@ -612,8 +616,12 @@ export async function openAssistantTask(
612616
.catch(error => {
613617
view.loading = false
614618
view.showSyncTaskRunning = false
615-
console.error('Assistant scheduling error', error?.response?.data?.ocs?.data?.message)
616-
showError(t('assistant', 'Assistant error') + ': ' + t('assistant', 'Something went wrong when scheduling the task'))
619+
const serverMessage = error?.response?.data?.ocs?.data?.message
620+
console.error('Assistant scheduling error', serverMessage)
621+
showError(
622+
t('assistant', 'Assistant error') + ': '
623+
+ (serverMessage || t('assistant', 'Something went wrong when scheduling the task')),
624+
)
617625
})
618626
}
619627
modalMountPoint.addEventListener('sync-submit', (data) => {

src/components/AssistantTextProcessingForm.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,10 @@ export default {
532532
this.$emit('action-button-clicked', { button, output: this.myOutputs })
533533
},
534534
onHistoryTryAgain(e) {
535-
this.$emit('try-again', e)
535+
// Load the task into the form instead of auto-submitting.
536+
// This lets the user review and fix stale enum values (e.g. removed models)
537+
// before resubmitting.
538+
this.$emit('load-task', e)
536539
},
537540
onHistoryLoadTask(e) {
538541
this.$emit('load-task', e)

src/components/fields/EnumField.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ export default {
7070
},
7171
7272
watch: {
73+
selectValue: {
74+
handler(newVal) {
75+
// If the current value doesn't match any available option, clear it.
76+
// This handles stale enum values (e.g. a removed model) when loading
77+
// a task from history.
78+
if (this.value !== null && this.value !== undefined && this.value !== '' && newVal === undefined) {
79+
this.$emit('update:value', undefined)
80+
}
81+
},
82+
immediate: true,
83+
},
7384
},
7485
7586
mounted() {

src/components/fields/TaskTypeFields.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default {
130130
getOptionalInputFieldOptions(field, key) {
131131
if (field.type === 'Enum'
132132
&& this.optionalShapeOptions !== null
133-
&& !Array.isArray(this.optionalShapeOptionsshapeOptions)
133+
&& !Array.isArray(this.optionalShapeOptions)
134134
&& this.optionalShapeOptions[key]
135135
) {
136136
return this.optionalShapeOptions[key]

src/views/AssistantPage.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ export default {
151151
.catch(error => {
152152
this.loading = false
153153
this.showSyncTaskRunning = false
154-
console.error('Assistant scheduling error', error?.response?.data?.ocs?.data?.message)
155-
showError(t('assistant', 'Assistant error') + ': ' + t('assistant', 'Something went wrong when scheduling the task'))
154+
const serverMessage = error?.response?.data?.ocs?.data?.message
155+
console.error('Assistant scheduling error', serverMessage)
156+
showError(
157+
t('assistant', 'Assistant error') + ': '
158+
+ (serverMessage || t('assistant', 'Something went wrong when scheduling the task')),
159+
)
156160
})
157161
.then(() => {
158162
})

0 commit comments

Comments
 (0)