Bug 2032917 - Restapi: after migrating Jackson to com.fasterxml.jackson, REST API's JSON default serializing mode is not ignoring properties with null values anymore
Summary: Restapi: after migrating Jackson to com.fasterxml.jackson, REST API's JSON de...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: General
Version: future
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ovirt-4.5.0
: 4.5.0
Assignee: Artur Socha
QA Contact: Barbora Dolezalova
URL:
Whiteboard:
Depends On: bonding, Bug, interface, multiple 1907798
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-12-15 13:30 UTC by Sharon Gratch
Modified: 2022-05-23 06:21 UTC (History)
2 users (show)

Fixed In Version: ovirt-engine-4.5.0
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-23 06:21:25 UTC
oVirt Team: Infra
Embargoed:
mperina: ovirt-4.5+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github oVirt ovirt-engine pull 144 0 None open restapi: do not serialized nullable fields 2022-03-14 08:35:45 UTC
Red Hat Issue Tracker RHV-44371 0 None None None 2021-12-15 13:31:56 UTC

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


Note You need to log in before you can comment on or make changes to this bug.