Home
Support Forums

Check my config: Recieved Error - "must have required property 'name'"

Support request solely concerns Netlify CMS.

Attempted to add file collection to config.yml for single file pages in Hugo, copying the example provided nearly verbatim, and received the following errors:

Config Errors:

'collections[0].files[0].fields[0]' must have required property 'name'
'collections[0].files[1].fields[0]' must have required property 'name'

Check your config.yml file.

This points us to the area in question in my configuration file. Which is located in the fields portion of the first and second code blocks defining file collections. As you will notice, the property 'name' is provided, and it does not appear there are indentation errors in my config.yaml. Which is often the root cause of errors of this nature.

The pertinent code blocks are:

collections:
    - label: "Pages"
      name: "pages"
      files:
        - label: "About Page"
          name: "about"
          identifier_field: "name"
          file: "content/about.md"
          description: "The About Us Page"
          fields:
            - {label: Title, name: title, widget: string}
            - {label: Date, name: date, widget: datetime}
            - {label: Description, name: description, widget: text}
            - label: Aliases
              name: aliases
              widget: list
              summary: "{{fields.aliases}}"
              fields:
                - {label: Alias, name: alias, widget: string}
            - {label: Author, name: author, widget: string}
            - {label: Body, name: body, widget: markdown}

        - label: "Regions"
          name: "regions"
          identifier_field: "name"
          file: "content/regions.md"
          fields:
            - {label: Title, name: title, widget: string}
            - {label: Date, name: date, widget: datetime}
            - {label: Author, name: author, widget: string}
            - {label: Body, name: body, widget: markdown}

I have run both yaml-lint and validyaml on the file, and it did not pick up anything. I also have tried rearranging the order of the declaration numerous ways, to no avail. Furthermore, I am baffled at what possibly could be continuing to cause the error. Is there something really basic I am overlooking?

You have a property identifier_field: "name", but no field called name. Remove the identifier field and you should be fine

Thank you very much for the assistance, Tom.

Unfortunately, this did not resolve the issue. The error occurred before the identifier_field was added, and it was added in an attempt to resolve the error. I probably should have removed it earlier.

Do you see anything else?

Well you do have a double colon in your code, but other than that it looks alright from a glance

- {label: Title, name:: title, widget: string}

Ooops, I thought I had removed that. It only existed here in the topic, and does not occur in the actual configuration file. If it did, it would naturally have generated an additional error stating so. I edited my previous post and removed it.

This issue has been resolved. I credit @tomrutgers for this, although like most geniuses of our era, he may be unaware of the brilliance of his suggestion. He responded:

This led me to experiment with adding a field labeled “name” to the collection.

fields:
            - {label: Name, name: name, widget: string}
            - {label: Title, name: title, widget: string}
            - {label: Date, name: date, widget: datetime}
            - {label: Description, name: description, widget: text}

Then it happened, the error changed and referred to the second line in the field list instead of the second.

Config Errors:

# So this:
'collections[0].files[0].fields[0]' must have required property 'name'

# Changed to this:
'collections[0].files[0].fields[1]' must have required property 'name'

Check your config.yml file.

This meant that the error specifically concerned that line and that line alone, and without any visible errors in syntax it must be something hidden, as in a hex error or corrupted line.

So, I just removed the line altogether, and proceeded to make a new entry in the field list with the exact same info as before.

“And boom goes the dynamite.” :rocket: :fireworks: :partying_face:

2 Likes

@anoduck

Thank you so much for coming back and sharing this detailed write up! This will most certainly be beneficial to future members who encounter something similar. @tomrutgers, nice work!!! :netliconfetti:

2 Likes

You are most sincerely welcome. Go Team!

1 Like