Repository navigation
fix(api): correct misleading error message on empty keyValuePairs - #3500
Conversation
updateQuestion() rejected an empty keyValuePairs array with the message "This form is archived and can not be modified". That message is unrelated to the actual cause and sends callers looking in the wrong place. The sibling methods updateForm() and updateOption() already report this case accurately, and updateQuestion()'s own @throws annotation documents it as "Empty keyValuePairs, will not update" too, so the string looks like a copy-paste leftover from the archived-form check further up. Only the message is changed. The exception type stays OCSBadRequestException so the HTTP status code is unaffected. Signed-off-by: Josef Behr <code@josef-behr.de> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
/backport to stable5.3 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Hello there, 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.) |
The problem
ApiController::updateQuestion()rejects an emptykeyValuePairsarray with:The form is not archived. The message has nothing to do with the actual cause, which sends callers looking in the wrong place.
Reproduction
Against Nextcloud 32.0.9 / Forms 5.3.3, on a form that is not archived:
Why this looks like a copy-paste leftover
logger->info()call on the line directly above already saysEmpty keyValuePairs, will not update.@throwsannotation documents this case asEmpty keyValuePairs, will not updateupdateForm()andupdateOption()both report it accuratelyScope
Only the message string changes.
There is a related inconsistency I deliberately left alone: the docblock and both sibling methods use
OCSForbiddenException(403) for this case, whileupdateQuestion()usesOCSBadRequestException(400). Aligning them would change the status code for existing clients, and 400 is arguably the more accurate one for an empty payload anyway. Happy to follow up in either direction if you have a preference.Context
Found while creating a form through the API.
🤖 Generated with Claude Code