Autogenerated migration script includes invalid "type": "markdown" line

We had some changes that included a new markdown field. The autogenerated migration script included this code:

console.log(‘Create Multiple - paragraph text field“ Card Description”(card_description) in block model“\ \uD83D\ \uDC81 Speaker Spotlight”(speaker_spotlight)’, );
await client.fields.create(‘fpLMqpz8S3G80CMeGrkjMQ’, {
    id: ‘GPVELgr1RU21Z7jTyE3eaw’,
    label: ‘Card Description’,
    field_type: ‘text’,
    api_key: ‘card_description’,
    validators: {
        required: {},
        length: {
            max: 820
        },
        sanitized_html: {
            sanitize_before_validation: true
        },
    },
    appearance: {
        addons: [],
        editor: ‘markdown’,
        parameters: {
            toolbar: \[‘bold’, ‘code’, ‘italic’, ‘link’, ‘ordered_list’, ‘strikethrough’, ‘unordered_list’, \],
        },
        type: ‘markdown’,
    },
    default_value: ‘’,
});

This resulted in an error that the “type” key was not permitted. Removing the type: 'markdown' line solved the problem, and didn’t seem to introduce any issues.

(Mod note: Cleaned up code formatting)

Hello @fitzage,

This should be fixed in CLI version 3.1.7: https://github.com/datocms/cli/issues/40#issuecomment-3460843439

Could you please confirm whether you’re on that version or an older one?

Ah, well I should have checked that. Probably the source of my previous errors also. We’re still on 2.0.23. :grimacing:

1 Like

I upgraded to 3.1.7 after your response 13 days ago, then I went to do a new migration today and got a similar error, but it appears to be related to single-line text fields (the multi-line fields ran fine, and the error occurred at the first single-line field).

Create Single-line string field "Day 1 Social Winner" (`day1_social_winner`) in model "🏆 AWS re:Invent Daily Winners" (`re_invent_daily_winners_page`)
[8] POST https://site-api.datocms.com/item-types/MPiSIkZ3SqK3m2NGY2f-fA/fields
[8] {
  "data": {
    "id": "P5g5LLO1Rw-nqi2ZDWuvPg",
    "type": "field",
    "attributes": {
      "label": "Day 1 Social Winner",
      "field_type": "string",
      "api_key": "day1_social_winner",
      "appearance": {
        "addons": [],
        "editor": "single_line",
        "parameters": {
          "heading": false,
          "placeholder": null
        },
        "type": null
      },
      "default_value": null
    },
    "relationships": {
      "fieldset": {
        "data": {
          "id": "WDZZtFwRTVaHYXc_t32C6Q",
          "type": "fieldset"
        }
      }
    }
  }
}
[8] Status: 422 (Unprocessable Entity)
[8] {
  "data": [
    {
      "id": "a9d52a",
      "type": "api_error",
      "attributes": {
        "code": "INVALID_FORMAT",
        "details": {
          "messages": [
            "#/data/attributes/appearance: failed schema #/definitions/field/links/0/schema/properties/data/properties/attributes/properties/appearance: \"type\" is not a permitted key."
          ]
        },
        "doc_url": "https://www.datocms.com/docs/content-management-api/errors#INVALID_FORMAT"
      }
    }
  ]
}

Now I see that there is 3.1.10 available, which may or may not fix the problem. This is getting tedious. :slight_smile:

Hmm, sorry @fitzage… that might be another related bug :frowning: I’ve let the dev know, but in the meantime, you can delete the "type": null line in data.attributes.appearance from the migration script and then run it again. If you find any other "type": nulls in the migration script, please delete or comment them all out.

Sorry about that!

@fitzage, could you please send me (via PM here, or a post, or emailing support@datocms.com) the broken migration script it generated, and/or let me know the command you used (including the project/env names) so I can try to replicate it and troubleshoot it better?

Well, I already migrated and I think I deleted the migration file (that I had edited out the "type": null lines.

In our current Corpsite project, the migration was when migrating AWS re:Invent Daily Winners as a completely new model, so perhaps you could do some testing with a similar model. One thing that could contribute here is that this is a single-instance model, which we’ve never used before.

If you need more information about the model I can give it to you, but it’s basically just a few multi-line text fields and a few single-line text fields. It seemed that the single-line versions are what triggered the issues.

Thank you @fitzage… I will try to replicate this and let you know if we can figure it out.

Edit: Hmm, it seems to be happening to me too. Possibly a regression? I’ll report it right away… sorry!

@fitzage

Sorry, the bug (it was indeed another bug) should be fixed for real now in 3.1.14! I’m so sorry it took us a while to track it down.


PS Separately, it looks to me like your Corpsite project currently only has one user, but they cannot get into it because they don’t have 2FA enabled and the project requires it. Was that intentional? Is this a project you only use programmatically, without ever logging into the CMS UI…? Feel free to separately DM me or email support@datocms.com if you want to discuss that part of it.

Thanks for getting that figured out!

We are using SSO with our corporate accounts, so, I’m not even sure about that one account or why it exists, but I think we’re good. :laughing:

1 Like