Uploaded image for project: 'Atlas'
  1. Atlas
  2. ATLAS-2933

Empty array attributes are returned as null instead of an empty list

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.1.0
    • None
    • None
    • None

    Description

       

      Given the following entity def:

      {
       "entityDefs": [
         {
           "name": "ExampleType",
           "superTypes": [],
           "typeVersion": "0.1",
           "attributeDefs": [
             {
               "name": "things",
               "typeName": "array<string>",
               "cardinality": "SINGLE",
               "isIndexable": false,
               "isOptional": false,
               "isUnique": false
             }
           ]
         }
       ]
      }
      

      I can POST a new entity with an empty array for the things attribute successfully:

      POST /api/atlas/v2/entity
      
      {
       "entity":{
       "typeName":"ExampleType",
       "attributes":{
         "things": []
       },
       "guid":"-thing",
       "version":1
       }
      }
      

      But when i GET the entity by guid, the attribute is null instead of the empty list:

      GET /api/atlas/v2/entity/guid/d5e33187-3293-4206-bcb8-807dc87c1440
      
      {
       "referredEntities": {},
       "entity": {
       "typeName": "ExampleType",
       "attributes": {
         "things": null
       },
       "guid": "d5e33187-3293-4206-bcb8-807dc87c1440",
       "status": "ACTIVE",
       "createdBy": "admin",
       "updatedBy": "admin",
       "createTime": 1540335741854,
       "updateTime": 1540335741854,
       "version": 1
       }
      }
      

      Atlas should preserve the original value of the create request as an empty list. Returning null here causes further confusion, because the attribute is defined with `isOptional: false` so any consumer of the entity would reasonably expect a non-null value.

      I tested this behavior against Atlas versions 1.0.0 and 1.1.0

      Attachments

        1. ATLAS-2933.patch
          26 kB
          Le Ma

        Activity

          People

            lma Le Ma
            cparker-civitas Cade Parker
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 10m
                2h 10m