Repository navigation
fix(api): add options only to questions that take them - #4000
Open
AndyScherzinger wants to merge 2 commits into
Open
AndyScherzinger wants to merge 2 commits into
AndyScherzinger wants to merge 2 commits into
Conversation
Member
Author
|
/backport to stable5.4 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Chartman123
reviewed
Nov 23, 2026
Chartman123
left a comment
Collaborator
There was a problem hiding this comment.
Two comments mainly about organizing our constants
The option types row and column were defined on the Option entity, while the question types, grid cell types and the other shared values live in Constants. Moving them there keeps the types an option can have next to the question types that use them. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The endpoint that creates options checked the form and the question, but not the question type, so options could be stored on short text, date, file, linear scale and other questions that have no choices. They were never shown or used and stayed as dead rows. The option type was not checked either, so a dropdown could get grid rows. Options are now accepted only for dropdown, checkbox, radio button and ranking questions (option type choice) and for grid questions (row or column), and are otherwise rejected with 400. A missing option type still means choice. Fixes #3981 Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
AndyScherzinger
force-pushed
the
fix/options-only-for-choice-questions
branch
from
November 23, 2026 07:50
bfdca39 to
142c37a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
POST /api/v3/forms/{formId}/questions/{questionId}/optionschecked the form and that the question belongs to it, but not the question type. Options could be added to short text, long text, date, time, color, file and linear scale questions, which have no choices. They were stored as dead rows: never shown, never used. The option type was not checked either, so a dropdown could get gridrowoptions or a gridchoiceoptions.Fixes #3981
Change
ApiController::newOption()now accepts options only for question types that use them:dropdown,multiple,multiple_uniqueandranking: option typechoicegrid: option typeroworcolumnAny other question type gets 400 "This question type takes no options", and an option type that does not fit the question gets 400 "Invalid option type for this question". A missing or
nulloption type still meanschoice, as documented. Options that are already stored stay untouched.docs/API_v3.md,docs/DataStructure.md(ranking useschoicetoo) andopenapi.jsonare updated.How to verify
POST …/questions/{shortQuestionId}/optionswith{"optionTexts": ["Coffee", "Tea"]}: 400, and the question still has no options.Unit test
testNewOptionOptionTypecovers every combination of question type and option type above, and the integration testtestCreateNewOptionRejectsQuestionWithoutOptionscovers the request from the issue.🤖 AI (if applicable)