Import "set" field type not working

Hello, I have a large data set (~4000 entries) that I want to import into my Cockpit CMS using the JSON importing tool, and it is mostly working correctly except for “set” type fields, which do not seem to be pulling in the data. All the other fields are importing correctly.

My set fields have a configuration like the following:

{
  "fields": [
    {
      "name": "tag",
      "label": "Tag",
      "type": "text"
    },
    {
      "name": "description",
      "label": "Description",
      "type": "text"
    }
  ],
  "display": null,
  "limit": null
}

and the corresponding JSON object looks like this:

    "_1xx": {
      "tag": "150",
      "description": "$aAbenaki"
    },

The really odd thing is that if I fill in an entry manually on the CMS then export the collection as JSON, it looks identical to the JSON file I am trying to import. Here is a short sample, the fields in question are _053 and _1xx.

The JSON I am trying to import:

[
  {
    "_ldr": "00398cz  a2200145n  4500",
    "_001": "sh00006813",
    "_003": "DLC",
    "_005": "20090114131843.0",
    "_008": "000523||\\dnannbbba\\\\\\\\\\\\\\\\\\\\|n\\ann\\\\\\\\\\\\",
    "_010": "$ash 00006813",
    "_040": "$aDLC$beng$cDLC$dDLC",
    "_053": {
      "indicator_2": "\\",
      "description": "$aE99.A13"
    },
    "_1xx": {
      "tag": "180",
      "description": "$xIndigenous influences"
    },
    "_revised_heading": "Indigenous influences",
    "_4xx": [
      {
        "value": {
          "tag": "480",
          "indicator_1": "\\",
          "indicator_2": "\\",
          "description": "$xIndian influences"
        }
      }
    ],
    "_667_68x": [
      {
        "value": {
          "tag": "680",
          "indicator_1": "\\",
          "indicator_2": "\\",
          "description": "$iUse as a topical subdivision under individual literatures."
        }
      }
    ]
  }
]

And the collection JSON exported out of Cockpit:

[
    {
        "_ldr": "00398cz  a2200145n  4500",
        "_revised_heading": "Indigenous influences",
        "_001": "sh00006813",
        "_003": "DLC",
        "_005": "20090114131843.0",
        "_008": "000523||\\dnannbbba\\\\\\\\\\\\\\\\\\\\|n\\ann\\\\\\\\\\\\",
        "_010": "$ash 00006813",
        "_040": "$aDLC$beng$cDLC$dDLC",
        "_073": null,
        "_1xx": {
            "tag": null,
            "description": null
        },
        "_4xx": [
            {
                "value": {
                    "tag": "480",
                    "indicator_1": "\\",
                    "indicator_2": "\\",
                    "description": "$xIndian influences"
                }
            }
        ],
        "_667_68x": [
            {
                "value": {
                    "tag": "680",
                    "indicator_1": "\\",
                    "indicator_2": "\\",
                    "description": "$iUse as a topical subdivision under individual literatures."
                }
            }
        ],
        "_by": "611f04e27f4a970d7f1d2951",
        "_mby": "611f04e27f4a970d7f1d2951",
        "_modified": 1629990921,
        "_053": {
            "indicator_2": null,
            "description": null
        },
        "_260": null,
        "_360": null,
        "_5xx": null,
        "_8xx": null,
        "_9xx": null,
        "_created": 1629990386,
        "_id": "6127adf2971e2c3d5f0d5921"
    }
]

Does anyone have any ideas into what could be going wrong? Is this a bug? Is there another way I can update those fields?

Thank you!

I tried to reproduce your problem and yes, there seems to be a bug.

My steps

  • created a simple collection with
    • text field
    • asset field
    • set field with text sub-fields
  • entered some data into all (sub)fields
  • saved
  • exported
    The values showed up correctly in my export (not null like in yours)
  • imported
    asset and set field were set to null

The problem starts on doImport when the parsed data is once more re-parsed to be then sent to Import::execute.
For any fields that have an object instead of a simple text value it expects a type key that is then compared with the field.type.
And that type key is completely missing.

I’d expect this type key to be set some time after the field-mapping is confirmed.

So yes, this is a bug.

Possible workaround (*not tested)

To get your import “working” you could disable lines 330,331 in the cockpit source and it might import fine.

Note: I filed a bug report Importing "object-structured" fields sets fields to `null` · Issue #1464 · agentejo/cockpit · GitHub

Ok thanks for checking it! I just subscribed to the issue to follow progress.
FWIW, I was able to push my data using the API /api/collections/save/ so I’m using that for now.

Yes, true. This is only an issue when importing via the UI.
Importing via the CLI or API is not affected by this.