From bae929d885a6dee577930e0e16168cc8e1569850 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 20 Nov 2026 11:13:11 +0100 Subject: [PATCH] fix(submit): tell respondents when they submit too often Since the submission endpoints are rate-limited, the server answers 429 with an empty body once the limit is hit. Submitting then only showed the generic error, and a file upload showed a message with an empty slot and a dangling colon, so respondents could think the form is broken. Show "Too many submissions. Please wait a minute and try again." instead, and drop the empty slot from the upload error. Ref: https://github.com/nextcloud/forms/issues/3924#issuecomment-7017007011 Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- src/components/Questions/QuestionFile.vue | 51 +++++++++++++---------- src/views/Submit.vue | 15 +++++-- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/components/Questions/QuestionFile.vue b/src/components/Questions/QuestionFile.vue index 0e6200182..d15a391aa 100644 --- a/src/components/Questions/QuestionFile.vue +++ b/src/components/Questions/QuestionFile.vue @@ -387,28 +387,35 @@ export default defineComponent({ }) } catch (error) { logger.error('Error while submitting the form', { error }) - showError( - t( - 'forms', - 'There was an error during submitting the file: {message}.', - { - message: - ( - error as { - response?: { - data?: { - ocs?: { - meta?: { - message?: string - } - } - } - } - } - ).response?.data?.ocs?.meta?.message ?? '', - }, - ), - ) + const errorResponse = ( + error as { + response?: { + status?: number + data?: { ocs?: { meta?: { message?: string } } } + } + } + ).response + const message = errorResponse?.data?.ocs?.meta?.message + if (errorResponse?.status === 429) { + showError( + t( + 'forms', + 'Too many submissions. Please wait a minute and try again.', + ), + ) + } else if (message) { + showError( + t( + 'forms', + 'There was an error during submitting the file: {message}.', + { message }, + ), + ) + } else { + showError( + t('forms', 'There was an error during submitting the file.'), + ) + } return } finally { diff --git a/src/views/Submit.vue b/src/views/Submit.vue index ca08a9a1f..ce5565fad 100644 --- a/src/views/Submit.vue +++ b/src/views/Submit.vue @@ -1110,15 +1110,24 @@ export default defineComponent({ deleteFormFieldFromLocalStorage() emitEvent('forms:last-updated:set', props.form.id) } catch (error) { - const errorMessage = ( + const response = ( error as { response?: { + status?: number data?: { ocs?: { meta?: { message?: string } } } } } - ).response?.data?.ocs?.meta?.message + ).response + const errorMessage = response?.data?.ocs?.meta?.message logger.error('Error while submitting the form', { error }) - if (errorMessage) { + if (response?.status === 429) { + showError( + t( + 'forms', + 'Too many submissions. Please wait a minute and try again.', + ), + ) + } else if (errorMessage) { showError( t( 'forms',