Clarify the 'towhat' inclusion validation message on policy creation. #18338
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.
https://bugzilla.redhat.com/show_bug.cgi?id=1663562
In this resolved bug / #18032, it was found that providing an invalid
towhat
value in the payload while creating aPolicy
record via the API would result in an unclear error message. The received message is the default error message for a failed Rails inclusion validation: "Towhat is not included in the list".This message can be (and was) mistakenly interpreted to mean
towhat
was not included in the payload structure, when it's actually referring to the inclusion list it's being validated against.This helps clarify the messaging to specify the list of valid "towhat" values, following established patterns throughout other model validations, such as:
manageiq/app/models/miq_widget.rb
Line 24 in 1db6992
This also updates a supportive spec which tests the validity of the policy record.
Links
Policy
Steps for Testing/QA
Send a
POST
API request to create aPolicy
by running:and entering the following payload (invalid
towhat
):Response Before:
Note the error message: "Towhat is not included in the list"
Response After:
Note the error message: "Towhat should be one of ContainerGroup, ContainerImage, ContainerNode, ContainerProject, ContainerReplicator, ExtManagementSystem, Host, PhysicalServer, Vm"