Bug 906366

Summary: Wrong Error Message in the Alert API
Product: [Other] RHQ Project Reporter: Fernando Ribeiro <fernando.ribeiro>
Component: RESTAssignee: Heiko W. Rupp <hrupp>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5   
Target Milestone: ---   
Target Release: RHQ 4.6   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-03 14:43:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Fernando Ribeiro 2013-01-31 14:12:06 UTC
Description of problem:

When the priority is not set in an AlertDefinitionRest object in a PUT call to "alert/definition/{id}", the API mis-sends the following error message:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rhqErrorWrapper>
  <message>Name is null</message> <!-- Should be "Priority is null" -->
</rhqErrorWrapper>

Version-Release number of selected component (if applicable):

4.5.1

How reproducible:

Steps to Reproduce:
1. Create an AlertDefinitionRest object without the priority set
2. Add the object to a PUT call to the "alert/definition/{id}" resource
3. Verify the returned error message
  
Actual results:

The API sends an error message that says "Name is null"

Expected results:

The API sends an error message that says "Priority is null"

Additional info:

Comment 1 Heiko W. Rupp 2013-02-01 13:27:01 UTC
The error message is shown, as there is indeed no name supplied for the enum:

Caused by: java.lang.NullPointerException: Name is null
	at java.lang.Enum.valueOf(Enum.java:235) [rt.jar:1.7.0_11]
	at org.rhq.core.domain.alert.AlertPriority.valueOf(AlertPriority.java:28) [rhq-core-domain-ejb3.jar:4.6.0-SNAPSHOT]
	at org.rhq.enterprise.server.rest.AlertDefinitionHandlerBean.updateDefinition(AlertDefinitionHandlerBean.java:279) [rhq-enterprise-server-ejb3.jar:4.6.0-SNAPSHOT]


As AlertsDefinitions need to have a priority, Low will be used if none supplied.

master 142d9dc590c0bd4

Comment 2 Fernando Ribeiro 2013-02-01 14:03:03 UTC
Great, you may also want to update the docs, which say that the priority is required.

Comment 3 Heiko W. Rupp 2013-09-03 14:43:23 UTC
Bulk closing of issues in old RHQ releases that are in production for a while now.

Please open a new issue when running into an issue.