datocms / js-datocms-client

NodeJS/Browser client for DatoCMS
https://www.datocms.com
MIT License
72 stars 37 forks source link

500 Error With New WYSIWYG Field Creation #121

Closed erasmussenBHTP closed 3 years ago

erasmussenBHTP commented 3 years ago

I'm running version 3.4.18 of the DatoCMS CLI and I'm having issues creating a migration with a multi-line text field that uses the wysiwyg editor. The CLI output says that a 500 Internal Server Error occurred with the following response data:

{
    "data": [
        {
            "id": "049ea5",
            "type": "api_error",
            "attributes": {
                "code": "EXCEPTION",
                "details": {
                    "message": "undefined method `new' for nil:NilClass"
                }
            }
        }
    ]
}

I'm able to work around this simply by creating the field through the UI, but I would prefer to manage all models and fields through migration scripts. Using the chrome dev tools when creating the field through the UI, the data appears to be identical to what my migration script has set.

Here's the script I'm trying to run

module.exports = async (client) => {
    const blogArticleSectionModel = await client.itemTypes.create({
        name: 'Blog Article Section',
        apiKey: 'blog_article_section',
        modularBlock: true
    });

    const sectionContent = await client.fields.create(blogArticleSectionModel.id, {
        label: 'Section Content',
        apiKey: 'section_content',
        fieldType: 'text',
        hint: '',
        localized: false,
        validators: {
            requried: {}
        },
        appearance: {
            editor: 'wysiwyg',
            parameters: {
                toolbar: [
                    'format', 'bold', 'italic', 'strikethrough', 'code', 'ordered_list',
                    'unordered_list', 'quote', 'table', 'link', 'image', 'show_source', 'align_left',
                    'align_center', 'align_right', 'align_justify', 'outdent', 'indent', 'fullscreen'
                ]
            },
            addons: [],
            type: 'wysiwyg'
        }
    });
};
stefanoverna commented 3 years ago

I think it has to do with the typo requried instead of required @erasmussenBHTP. Having that said, we should not break with a 500 :)

erasmussenBHTP commented 3 years ago

Whoops! That was definitely the issue. Thanks for catching that.