Skip to content

fix: skip short answer validation for empty optional answers - #3803

Merged
Chartman123 merged 1 commit into
nextcloud:mainfrom
orshih6:contribot/issue-3802
Nov 13, 2026
Merged

Chartman123 merged 1 commit into
nextcloud:mainfrom
orshih6:contribot/issue-3802

Conversation

@orshih6

@orshih6 orshih6 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

When a respondent types into an optional short-text question that has a validation type (email, phone, number or regex) and then clears it, the frontend still sends [''] for that question. validateSubmission then passed the empty string to validateShortQuestion, which rejected it. The result was "Invalid input for question ..." and the form couldn't be submitted.

Empty answers are already dropped when answers are stored (storeAnswersForQuestion skips ''), so an empty short answer just means "not answered". Format validation is now skipped for it. Required questions are unaffected, because the earlier required check still rejects an empty answer with "Question ... is required.".

Tests: I added two testValidateSubmission data sets, an empty email answer on an optional question (now accepted) and on a required question (still rejected as required). The first one fails without this change. I ran the testValidateSubmission cases from SubmissionServiceTest with PHPUnit 10.5 and the nextcloud/ocp stubs, not a full server checkout, and they all pass. php-cs-fixer reports no changes.

Fixes #3802


This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.

@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Chartman123

Copy link
Copy Markdown
Collaborator

@orshih6 thanks for your contribution :) Please correctly sign-off your commit so that the pipeline gets green

@Chartman123

Copy link
Copy Markdown
Collaborator

/backport to stable5.4

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label Oct 25, 2026
@Chartman123 Chartman123 added bug Something isn't working php PHP related ticket 3. to review Waiting for reviews feature: 📝 submitting responses labels Oct 25, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@Chartman123

Copy link
Copy Markdown
Collaborator

@orshih6 could you please fix the DCO workflow by signing off your commit? I'd like to merge this.

@Chartman123
Chartman123 merged commit e15e9f4 into nextcloud:main Nov 13, 2026
51 checks passed
@backportbot backportbot Bot removed the backport-request Pending backport by the backport-bot label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug Something isn't working feature: 📝 submitting responses feedback-requested php PHP related ticket

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid input for question "Email".

2 participants