Wrong schema definition for jsonschema validation

Bug #2059754 reported by Masaki UENO
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tacker
In Progress
Undecided
Itsuro Oda

Bug Description

In the Tacker Antelope implementation, schema definition of `CpProtocolData` has a wrong enum definition, which causes validation error when a LCM request is sent from clients.

When an InstantiateVnfRequest is sent from a client to Tacker, the client received 400 Bad Request.

```
{"status": 400, "detail": "Invalid input for field/attribute layerProtocol. Value: IP_OVER_ETHERNET. 'IP_OVER_ETHERNET' is not one of 'IP_OVER_ETHERNET'", "title": "Bad Request"}
```

Parameter of InstantiateVnfRequest is as follows:

```
{
  "flavourId": "simple",
  "instantiationLevelId": "instantiation_level_1",
  "extVirtualLinks": [
    {
      "id": "270f1e37-0d38-4e75-869a-158737d48a1a",
      "resourceId": "270f1e37-0d38-4e75-869a-158737d48a1a",
      "extCps": [
        {
          "cpdId": "VDU1_CP1",
          "cpConfig": {
            "VDU1_CP1": {
              "cpProtocolData": [
                {
                  "layerProtocol": "IP_OVER_ETHERNET",
                  "ipOverEthernet": {
                    "ipAddresses": [
                      {
                        "type": "IPV4",
                        "numDynamicAddresses": 1
                      }
                    ]
                  }
                }
              ]
            }
          }
        },
        {
          "cpdId": "VDU2_CP1",
          "cpConfig": {
            "VDU2_CP1": {
              "cpProtocolData": [
                {
                  "layerProtocol": "IP_OVER_ETHERNET",
                  "ipOverEthernet": {
                    "ipAddresses": [
                      {
                        "type": "IPV4",
                        "fixedAddresses": [
                          "192.168.200.101"
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      ]
    }
  ]
}
```

In the sample described in JSON schema document[1], value type of "enum" is array. However, JSON schema of CpProtocolData is defined as follows[2]:

```
CpProtocolData = {
    'type': 'object',
    'properties': {
        'layerProtocol': {
            'type': 'string',
            'enum': 'IP_OVER_ETHERNET'},
        'ipOverEthernet': IpOverEthernetAddressData,
    },
    'required': ['layerProtocol'],
    'additionalProperties': True,
}
```

I think the root cause of this behavior is that `properties.layerProtocol.enum` is not defined as array, thus the following will resolve this issue.

```
CpProtocolData = {
    'type': 'object',
    'properties': {
        'layerProtocol': {
            'type': 'string',
            'enum': ['IP_OVER_ETHERNET']},
        'ipOverEthernet': IpOverEthernetAddressData,
    },
    'required': ['layerProtocol'],
    'additionalProperties': True,
}
```

--- References ---

[1] https://json-schema.org/understanding-json-schema/reference/enum
[2] https://opendev.org/openstack/tacker/src/branch/stable/2023.1/tacker/sol_refactored/api/schemas/common_types.py#L194-L199

description: updated
description: updated
Changed in tacker:
status: New → In Progress
Itsuro Oda (oda-g)
Changed in tacker:
assignee: nobody → Itsuro Oda (oda-g)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.