Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2032917

Summary: Restapi: after migrating Jackson to com.fasterxml.jackson, REST API's JSON default serializing mode is not ignoring properties with null values anymore
Product: [oVirt] ovirt-engine Reporter: Sharon Gratch <sgratch>
Component: GeneralAssignee: Artur Socha <asocha>
Status: CLOSED CURRENTRELEASE QA Contact: Barbora Dolezalova <bdolezal>
Severity: high Docs Contact:
Priority: high    
Version: futureCC: bugs, mperina
Target Milestone: ovirt-4.5.0Flags: mperina: ovirt-4.5+
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.5.0 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-23 06:21:25 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:
Bug Depends On: 499109, 1907798    
Bug Blocks:    

Description Sharon Gratch 2021-12-15 13:30:07 UTC
Description of problem:

It seems that after migrating Jackson to com.fasterxml.jackson
(https://gerrit.ovirt.org/113872) then the REST API behavior for serializing
JSON properties with a null value have changed.

Before this upgrade, those properties with null values were ignored by default and now they are not.
It seems that it impacts all rest api endpoints. 

E.g. comparing the response of api/users/<id>/sshpublickeys
on 4.4.x (before migration to com.fasterxml.jackson):

{
  "ssh_public_key" : [ {
    "content" : "ssh-rsa AAAAB3NzaC1yc2EAAA ....",
    "user" : {
      "href" : "/ovirt-engine/api/users/1cdf57d4-1179-11ec-8563-52540012eda2",
      "id" : "1cdf57d4-1179-11ec-8563-52540012eda2"
    },
    "href" : "/ovirt-engine/api/users/1cdf57d4-1179-11ec-8563-52540012eda2/sshpublickeys/3b31acd9-c23a-43e8-ab4a-ad4ede686f96",
    "id" : "3b31acd9-c23a-43e8-ab4a-ad4ede686f96"
  } ]
}

on 4.5 (master branch)

{
  "ssh_public_key" : [ {
    "content" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQA.....",
    "user" : {
      "department" : null,
      "domain_entry_id" : null,
      "email" : null,
      "last_name" : null,
      "logged_in" : null,
      "namespace" : null,
      "password" : null,
      "principal" : null,
      "user_name" : null,
      "user_options" : null,
      "domain" : null,
      "groups" : null,
      "options" : null,
      "permissions" : null,
      "roles" : null,
      "ssh_public_keys" : null,
      "tags" : null,
      "actions" : null,
      "name" : null,
      "description" : null,
      "comment" : null,
      "creation_status" : null,
      "link" : null,
      "href" : "/ovirt-engine/api/users/60cce70c-b2a1-11e8-a594-001a4a013f3d",
      "id" : "60cce70c-b2a1-11e8-a594-001a4a013f3d"
    },
    "actions" : null,
    "name" : null,
    "description" : null,
    "comment" : null,
    "creation_status" : null,
    "link" : null,
    "href" : "/ovirt-engine/api/users/60cce70c-b2a1-11e8-a594-001a4a013f3d/sshpublickeys/876990d4-287c-43e9-81a6-cd5ec0fca88a",
    "id" : "876990d4-287c-43e9-81a6-cd5ec0fca88a"
  } ],
  "actions" : null,
  "size" : null,
  "total" : null,
  "active" : null
}


Actual results:
- web-ui fails - fetching all those null values for properties that were fetched as undefined till now, causes web-ui to fail.

-rest api responses size are now significantly larger due to adding all those null value properties and the response time is larger as well.

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

How reproducible:
100%

Comment 1 Artur Socha 2022-03-14 08:41:44 UTC
Fixed.  Current output looks like that: 

curl -k -H  "Accept: application/json"  -H "Authorization: Bearer <access_token>" 'https://workstation.dom:8443/ovirt-engine/api/users/a1119f36-75d3-11eb-a179-309c23f67dcf/sshpublickeys'
{
  "ssh_public_key" : [ {
    "content" : "<SSH_KEY>",
    "user" : {
      "href" : "/ovirt-engine/api/users/a1119f36-75d3-11eb-a179-309c23f67dcf",
      "id" : "a1119f36-75d3-11eb-a179-309c23f67dcf"
    },
    "href" : "/ovirt-engine/api/users/a1119f36-75d3-11eb-a179-309c23f67dcf/sshpublickeys/39105823-3331-4bb9-a9ac-cab5dced8a29",
    "id" : "39105823-3331-4bb9-a9ac-cab5dced8a29"
  } ]
}%

Comment 2 Barbora Dolezalova 2022-05-04 12:26:52 UTC
Verified in ovirt-engine-4.5.0.4-0.1.el8ev.noarch
Null properties are excluded