Fixes #39372 - Extract displayMessage from validation errors#655
Open
chris1984 wants to merge 1 commit into
Open
Fixes #39372 - Extract displayMessage from validation errors#655chris1984 wants to merge 1 commit into
chris1984 wants to merge 1 commit into
Conversation
c5c5457 to
47926d4
Compare
jeremylenz
reviewed
May 29, 2026
When the Foreman/Katello API returns validation errors (422 status),
it includes detailed error messages in the 'displayMessage' field.
The exception handler was only checking 'message' and 'full_messages',
causing detailed error information to be lost.
This commit updates handle_unprocessable_entity to check for
'displayMessage' first, matching the behavior of handle_foreman_error
which already handles this field correctly.
Before:
Could not update the host
After:
Could not update the host:
Validation failed: Host example.com: Cannot add content view
environment to content facet. The host's content source does
not sync lifecycle environment 'Library'.
47926d4 to
2eb4b14
Compare
jeremylenz
approved these changes
May 29, 2026
jturel
reviewed
May 29, 2026
| response = JSON.parse(e.response) | ||
| response = HammerCLIForeman.record_to_common_format(response) unless response.has_key?('message') | ||
| print_error response['message'] || response['full_messages'] | ||
| print_error response['message'] || response['full_messages'] || response['displayMessage'] |
Contributor
There was a problem hiding this comment.
Is displayMessage purely a Katello-ism? We are on the 5.0 release cycle; if Katello can align its API with the expectations already here, that'd be a win IMO.
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.
When the Foreman/Katello API returns validation errors (422 status), it includes detailed error messages in the 'displayMessage' field. The exception handler was only checking 'message' and 'full_messages', causing detailed error information to be lost.
This commit updates handle_unprocessable_entity to check for 'displayMessage' first, matching the behavior of handle_foreman_error which already handles this field correctly.
Before:
Could not update the host
After:
Could not update the host:
Validation failed: Host example.com: Cannot add content view
environment to content facet. The host's content source does
not sync lifecycle environment 'Library'.
Before patch:
After patch:
Testing Steps:
Create multiple Content Views (e.g., cv_1 & cv_2) and multiple Lifecycle Environments (e.g., 'Library' and 'Dev').
Publish new versions of all Content Views and promote them to the 'Dev' lifecycle environment.
Add only the 'Dev' lifecycle environment to the external Capsule, ensuring that the 'Library' lifecycle environment is not added. Then, synchronize the Capsule server.
Register the client to the Capsule server.
Try to update the hosts content view environments to one not synced on the capsule
hammer -d host update --id 3 --content-view-environments Library/ZooVerify you see the real error and not the generic can't update host error