Bug 1273932

Summary: RestAPI returns 500 instead of 400 when sending invalid JSON
Product: [oVirt] ovirt-engine Reporter: Roman Mohr <rmohr>
Component: RestAPIAssignee: Roman Mohr <rmohr>
Status: CLOSED CURRENTRELEASE QA Contact: Lucie Leistnerova <lleistne>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.0.0CC: bugs, gklein, rmohr
Target Milestone: ovirt-4.0.0-alphaFlags: juan.hernandez: ovirt-4.0.0?
rule-engine: planning_ack+
juan.hernandez: devel_ack+
pstehlik: testing_ack+
Target Release: 4.0.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt 4.0.0 alpha1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-08-17 14:37:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
server.log none

Description Roman Mohr 2015-10-21 14:12:47 UTC
Created attachment 1085142 [details]
server.log

Description of problem:

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


How reproducible:

Send a json to the server with non existing fields.

Steps to Reproduce:
1.PUT to https://localhost:8443/ovirt-engine/api/clusters/<cluster:id>
{
"scheduling_policy" : { "policy" : "test_policy"}
}

Actual results:

Receiving an internal server error (500) instead of invalid request(400)

Expected results:

Receiving invalid request(400)

Additional info:

In server.log:

  Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.constructor.BaseConstructor from [Module "org.ovirt.engine.api.restapi-definition:main" from local m      odule loader @627551fb (finder: local module finder @2b552920 (roots: /home/rmohr/ovirt-engines/master/var/lib/ovirt-engine/jboss_runtime/modules/00-modules-common,      /home/rmohr/ovirt-engines/master/var/lib/ovirt-engine/jboss_runtime/modules/01-ovirt-engine-extension-aaa-jdbc-modules,/home/rmohr/ovirt-engines/master/var/lib/ovir      t-engine/jboss_runtime/modules/02-ovirt-engine-wildfly-modules,/home/rmohr/ovirt-engines/master/var/lib/ovirt-engine/jboss_runtime/modules/02-ovirt-engine-wildfly-m      odules/system/layers/base))]


In engine.log:
  2015-10-21 15:43:15,948 ERROR [org.ovirt.engine.api.restapi.resource.validation.JsonExceptionMapper] (default task-1) [] Exception: org.codehaus.jackson.map.exc.Un       recognizedPropertyException: Unrecognized field "policy" (Class org.ovirt.engine.api.model.SchedulingPolicy), not marked as ignorable

Comment 1 Juan Hernández 2015-10-21 14:27:57 UTC
Is "Version" correct, did you find this issue in the 3.6 branch?

Comment 2 Roman Mohr 2015-10-21 14:31:03 UTC
Was on master. Corrected that. Will try to reproduce it on the 3.6 branch.

Comment 3 Juan Hernández 2015-10-21 14:32:01 UTC
This won't happen in 3.6, it is a side effect of removing YAML support, and that only happened in the master branch.

Comment 4 Lucie Leistnerova 2016-08-17 08:28:22 UTC
call with mentioned json or syntactically incorrect json returns 400 Bad Request

verified in ovirt-engine-restapi-4.0.2.6-0.1.el7ev.noarch