contentful/contentful-import

Import fails on "Importing Editor Interfaces" phase

marcin-bo opened this issue · 13 comments

Hi,

When I export data from one space using contentful-export tool and try to import it to another space I get errors in phase named "Importing Editor Interfaces". We modified our content models by removing some fields and it seems that file with exported data contains those removed fields in "editorInterfaces": [] array. Here is error I get:

"data": {
        "status": 422,
        "statusText": "Unprocessable Entity",
        "message": "Validation error",
        "details": {
          "errors": [
            {
              "details": "The control's \"fieldId\" must map to a content types field id",
              "path": [
                "controls",
                4,
                "fieldId"
              ],
              "value": "developmentText"
            }
          ]
        },

After removing fields that cause errors from "editorInterfaces": [] array ("developmentText" in the above example) the import script works properly. So it seems that contentful-export fetches old & unneeded data that contentful-import script cannot handle.

Cheers!

How old is the space you are exporting from? Looks like the validation did not catch the wrong value when the editorInterface was set in the first place 🤔

I am very sure this can't happen to new spaces since our API side validation would not allow to set such an editor interface.

Maybe add these case to our validations? @Khaledgarbaya?

We started to use this space in November or December last year.

Ahh I mixed something up, thats about the field id not the editor interface type.

This must be a bug, maybe even on API side since the following code should make sure that you get the interfaces of the content types you are actually exporting. Maybe the field id was changed and somehow it was not propagated to the editor interface fields id. https://github.com/contentful/contentful-export/blob/master/lib/tasks/get-space-data.js#L62-L67

Can you locate which content type is the faulty one and paste the output of the following here?

const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => space.getEditorInterfaceForContentType('<content_type_id>'))
.then((editorInterface) => console.log(editorInterface))
.catch(console.error)

thx

Not sure if I did it correclty but here's the output I got:

Deprecated: Space.getEditorInterfaceForContentType() will be removed in version 6.0. Please migrate your code to use the new environments API.
{ sys:
   { id: 'default',
     type: 'EditorInterface',
     space: { sys: [Object] },
     version: 24,
     createdAt: '2017-11-22T15:41:28.531Z',
     createdBy: { sys: [Object] },
     updatedAt: '2018-01-18T09:00:25.177Z',
     updatedBy: { sys: [Object] },
     contentType: { sys: [Object] },
     environment: { sys: [Object] } },
  controls:
   [ { fieldId: 'title', settings: [Object], widgetId: 'singleLine' },
     { fieldId: 'machineName',
       settings: [Object],
       widgetId: 'singleLine' },
     { fieldId: 'widgetTitle', widgetId: 'singleLine' },
     { fieldId: 'widgetText', widgetId: 'multipleLine' },
     { fieldId: 'developmentText', widgetId: 'entryLinkEditor' } ] }

Yeah gives me a first insight. Can you please also post the outcome of:

client.getSpace('<space_id>')
.then((space) => space.getContentType('<content_type_id>'))
.then((contentType) => console.log(contentType))
.catch(console.error)

🙇

Deprecated: Space.getContentType() will be removed in version 6.0. Please migrate your code to use the new environments API.
{ sys:
   { space: { sys: [Object] },
     id: 'developmentStep',
     type: 'ContentType',
     createdAt: '2017-11-22T15:41:28.040Z',
     updatedAt: '2018-05-28T12:26:39.580Z',
     environment: { sys: [Object] },
     createdBy: { sys: [Object] },
     updatedBy: { sys: [Object] },
     publishedCounter: 46,
     version: 95,
     publishedBy: { sys: [Object] },
     publishedVersion: 94,
     firstPublishedAt: '2017-11-22T15:41:28.425Z',
     publishedAt: '2018-05-28T12:26:39.580Z' },
  displayField: 'title',
  name: 'Development Step Widget',
  description:
   'Storing title and text for widget and also holds a reference for a development step text.',
  fields:
   [ { id: 'title',
       name: 'Title',
       type: 'Symbol',
       localized: false,
       required: false,
       validations: [],
       disabled: false,
       omitted: false },
     { id: 'machineName',
       name: 'Machine name',
       type: 'Symbol',
       localized: false,
       required: true,
       validations: [Array],
       disabled: false,
       omitted: false },
     { id: 'startDay',
       name: 'Start day',
       type: 'Integer',
       localized: false,
       required: false,
       validations: [],
       disabled: false,
       omitted: false },
     { id: 'endDay',
       name: 'End day',
       type: 'Integer',
       localized: false,
       required: false,
       validations: [],
       disabled: false,
       omitted: false },
     { id: 'widgetTitle',
       name: 'Widget title',
       type: 'Symbol',
       localized: true,
       required: false,
       validations: [],
       disabled: false,
       omitted: false },
     { id: 'widgetText',
       name: 'Widget text',
       type: 'Text',
       localized: true,
       required: true,
       validations: [],
       disabled: false,
       omitted: false },
     { id: 'mood',
       name: 'Mood',
       type: 'Symbol',
       localized: false,
       required: true,
       validations: [Array],
       disabled: false,
       omitted: false } ] }

Can it be the case developmentText was a field which got deleted at some point? 🤔

Yes, that's the case. We removed developmentText field from content model.

I am escalating this issue internally. I'll let you know when I know more :)

Hey @marcin-bo,

we identified the issue and will fix it as soon as possible. I'll keep the issue open to track progress.

Thanks a lot for the report!

Best,
Benedikt

@axe312ger I ran into this (or similar) error today. Guess it is not fixed yet :/

Also run the script you provided, my outputs are as follows:

Output of the script:

  sys: {
    id: 'default',
    type: 'EditorInterface',
    space: { sys: [Object] },
    version: 15,
    createdAt: '2021-12-20T11:43:43.917Z',
    createdBy: { sys: [Object] },
    updatedAt: '2022-02-04T09:08:11.966Z',
    updatedBy: { sys: [Object] },
    contentType: { sys: [Object] },
    environment: { sys: [Object] }
  },
  controls: [
    {
      fieldId: 'label',
      settings: [Object],
      widgetId: 'singleLine',
      widgetNamespace: 'builtin'
    },
    {
      fieldId: 'url',
      settings: [Object],
      widgetId: 'urlEditor',
      widgetNamespace: 'builtin'
    },
    {
      fieldId: 'link',
      settings: [Object],
      widgetId: 'urlEditor',
      widgetNamespace: 'builtin'
    },
    {
      fieldId: 'page',
      settings: [Object],
      widgetId: 'entryLinkEditor',
      widgetNamespace: 'builtin'
    },
    {
      fieldId: 'redirectTo',
      settings: [Object],
      widgetId: 'singleLine',
      widgetNamespace: 'builtin'
    }
  ]
}

Error of import:

 "data": {
        "status": 422,
        "statusText": "Unprocessable Entity",
        "message": "Validation error",
        "details": {
          "errors": [
            {
              "details": "The control's \"fieldId\" must map to a content type field id",
              "path": [
                "controls",
                1,
                "fieldId"
              ],
              "value": "url"
            }
          ]
        },
...```

The url field is a Symbol field using the urlEditor and a regex for validation.

EDIT: Saw that you provided two different scripts. Above one was using the getEditorInterfaceForContentType. After I ran it with getContentType I saw that we no longer have the url field on the Content Type.

@Chuvisco88 sorry, I am not responsible for this codebase anymore. Please reach out to Contentful support if you need urgent help.

This ticket has been closed due to inactivity. If you still need help resolving your issue, please reach out through our community Slack, or contact Contentful support directly.