Skip to content

fix(api): correct misleading error message on empty keyValuePairs#3500

Open
josefbehr wants to merge 1 commit into
nextcloud:mainfrom
josefbehr:fix/empty-keyvaluepairs-error-message
Open

fix(api): correct misleading error message on empty keyValuePairs#3500
josefbehr wants to merge 1 commit into
nextcloud:mainfrom
josefbehr:fix/empty-keyvaluepairs-error-message

Conversation

@josefbehr

Copy link
Copy Markdown
Contributor

The problem

ApiController::updateQuestion() rejects an empty keyValuePairs array with:

This form is archived and can not be modified

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:

PATCH /ocs/v2.php/apps/forms/api/v3/forms/{formId}/questions/{questionId}
Content-Type: application/json

{"keyValuePairs":{}}
400 | This form is archived and can not be modified

Why this looks like a copy-paste leftover

  • The logger->info() call on the line directly above already says Empty keyValuePairs, will not update.
  • The method's own @throws annotation documents this case as Empty keyValuePairs, will not update
  • The sibling methods updateForm() and updateOption() both report it accurately
  • The string matches the archived-form check ~20 lines further up verbatim

Scope

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, while updateQuestion() uses OCSBadRequestException (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

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>
@Chartman123

Copy link
Copy Markdown
Collaborator

/backport to stable5.3

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Controller/ApiController.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-request Pending backport by the backport-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants