From 29bb1079b3f2bd259b0a5cfee60c9b9a1a4bf01f Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 16 Nov 2026 20:19:49 +0100 Subject: [PATCH 1/2] fix(submission): only accept a list of values as an answer An answer is a list of values, as the API describes it. Other values are rejected as an invalid answer with a 400 instead of failing with a server error, and an empty list counts as no answer, so an optional question answered with an empty list is not checked any further. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- lib/Service/SubmissionService.php | 24 +++++++++++- tests/Unit/Service/SubmissionServiceTest.php | 41 ++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/lib/Service/SubmissionService.php b/lib/Service/SubmissionService.php index 99c9d38b43..ef08a28922 100644 --- a/lib/Service/SubmissionService.php +++ b/lib/Service/SubmissionService.php @@ -399,7 +399,11 @@ public function validateSubmission(array $questions, array $answers, string $for // Check by questions foreach ($questions as $question) { $questionId = $question['id']; - $questionAnswered = array_key_exists($questionId, $answers); + $questionAnswered = array_key_exists($questionId, $answers) && $answers[$questionId] !== []; + + if ($questionAnswered && !self::isListOfValues($question['type'], $answers[$questionId])) { + throw new \InvalidArgumentException(sprintf('Invalid answer for question "%s".', $question['text'])); + } // Check if all required questions have an answer if ($question['isRequired'] @@ -601,4 +605,22 @@ private function validateShortQuestion(array $question, string $data): bool { return false; } } + + /** + * Whether the answer is a list of values: texts or numbers, or uploaded files for file questions + * + * @param string $questionType the question type + * @param mixed $answer the answer + */ + private static function isListOfValues(string $questionType, mixed $answer): bool { + if (!is_array($answer) || !array_is_list($answer)) { + return false; + } + foreach ($answer as $value) { + if ($questionType === Constants::ANSWER_TYPE_FILE ? !is_array($value) : !is_scalar($value)) { + return false; + } + } + return true; + } } diff --git a/tests/Unit/Service/SubmissionServiceTest.php b/tests/Unit/Service/SubmissionServiceTest.php index 62bc6473d1..e6ba8b2802 100644 --- a/tests/Unit/Service/SubmissionServiceTest.php +++ b/tests/Unit/Service/SubmissionServiceTest.php @@ -885,6 +885,47 @@ public function dataValidateSubmission() { // Expected Result null, ], + 'empty-answers-to-optional-questions' => [ + [ + ['id' => 1, 'type' => 'short', 'text' => 'q1', 'isRequired' => false], + ['id' => 2, 'type' => 'multiple', 'text' => 'q2', 'isRequired' => false, 'extraSettings' => ['optionsLimitMin' => 2], 'options' => [ + ['id' => 3], + ['id' => 5], + ]], + ], + ['1' => [], '2' => []], + null, + ], + 'empty-answer-to-required-question' => [ + [ + ['id' => 1, 'type' => 'short', 'text' => 'q1', 'isRequired' => true], + ], + ['1' => []], + 'Question "q1" is required.', + ], + 'answer-that-is-no-list' => [ + [ + ['id' => 1, 'type' => 'short', 'text' => 'q1', 'isRequired' => false], + ], + ['1' => ['first' => 'text']], + 'Invalid answer for question "q1".', + ], + 'answer-with-a-value-that-is-no-text' => [ + [ + ['id' => 1, 'type' => 'short', 'text' => 'q1', 'isRequired' => false], + ], + ['1' => [null]], + 'Invalid answer for question "q1".', + ], + 'answer-that-is-no-array' => [ + [ + ['id' => 1, 'type' => 'multiple_unique', 'text' => 'q1', 'isRequired' => false, 'options' => [ + ['id' => 3], + ]], + ], + ['1' => '3'], + 'Invalid answer for question "q1".', + ], 'invalid-short-phone' => [ // Questions [ From 8598a57723afa88a7a7d72545b680834e36e9e85 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 25 Nov 2026 09:26:52 +0100 Subject: [PATCH 2/2] ci: bump codecov/codecov-action from 5.5.1 to 7.0.0 The uploader that v5.5.1 downloads is now signed with a key the action does not know, so the signature check fails and the coverage upload fails the PHPUnit and Node jobs. v7.0.0 is the version stable5.3 runs. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- .github/workflows/node-test.yml | 2 +- .github/workflows/phpunit-sqlite.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-test.yml b/.github/workflows/node-test.yml index b774d3a0a1..83aeb8c903 100644 --- a/.github/workflows/node-test.yml +++ b/.github/workflows/node-test.yml @@ -93,7 +93,7 @@ jobs: run: npm run test:coverage --if-present - name: Collect coverage - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 with: disable_search: true files: ./coverage/lcov.info diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index f78735eef4..be05167a7b 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -157,7 +157,7 @@ jobs: run: composer run test:unit - name: Upload Unit coverage - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 with: working-directory: apps/${{ env.APP_NAME }} disable_search: true @@ -184,7 +184,7 @@ jobs: run: composer run test:integration - name: Upload Integration coverage - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 with: working-directory: apps/${{ env.APP_NAME }} disable_search: true