decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.93k stars 3.04k forks source link

TypeError: e.join is not a function #4481

Closed kitella1 closed 4 years ago

kitella1 commented 4 years ago

Describe the bug Cannot open any collection entries on my CMS.

To Reproduce I just tried to open a collection entry and it crashed, saving that e.join is not a function.

Expected behavior I should be able to open the entry and start editing. When I click on the entry, I'm met with an error page.

Screenshots Screenshot (39)]

Applicable Versions:

CMS configuration


publish_mode: simple
slug:
  encoding: unicode
  clean_accents: false
  sanitize_replacement: "-"
backend:
  name: git-gateway
  branch: master
media_folder: static/img
public_folder: /img
collections:
  - sortable_fields:
      - commit_date
      - title
      - date
      - commit_author
      - description
    view_filters: []
    meta: {}
    name: prototype
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    editor:
      preview: false
    folder: content/project
    publish: true
    label: Prototype
    format: json
    fields:
      - label: Title
        name: title
        widget: string
      - label: Hero Image
        name: hero
        widget: image
        allow_multiple: false
        required: false
      - label: Date of Completion
        name: date
        widget: datetime
        date_format: YYYY
      - label: Technologies and Skills
        name: techskills
        widget: list
        field:
          label: List Item
          name: item
          widget: string
      - label: High Concept
        name: highconcept
        widget: text
      - label: Video
        name: video
        widget: file
        required: false
      - label: Flowchart
        name: flowchart
        widget: code
        required: false
      - label: Description
        name: description
        widget: text
      - label: Supporting Document
        name: document
        widget: file
        required: false
      - label: Gallery Images
        name: gallery
        widget: list
        fields:
          - label: Image
            name: image
            widget: image
          - label: Image Description (For Screen Readers)
            name: alt
            widget: string
      - label: External Links
        name: links
        widget: list
        required: false
        fields:
          - label: Type
            name: linktype
            widget: select
            options:
              - Game Files
              - Other URL
          - label: "Location Name: i.e. ArtStation, Steam"
            name: linkname
            widget: string
          - label: Target
            name: linktarget
            widget: string
    create: true
  - sortable_fields:
      - commit_date
      - title
      - date
      - commit_author
      - description
    view_filters: []
    meta: {}
    name: desdoc
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    editor:
      preview: false
    folder: content/project
    publish: true
    label: Design Document
    format: json
    fields:
      - label: Title
        name: title
        widget: string
      - label: Hero Image
        name: hero
        widget: image
        allow_multiple: false
        required: false
      - label: Date of Completion
        name: date
        widget: datetime
        date_format: YYYY
      - label: Technologies and Skills
        name: techskills
        widget: list
        field:
          label: List Item
          name: item
          widget: string
      - label: Flowchart
        name: flowchart
        widget: code
        required: false
      - label: High Concept
        name: highconcept
        widget: text
      - label: Supporting Document
        name: document
        widget: file
        required: false
      - label: Description
        name: description
        widget: text
      - label: External Links
        name: links
        widget: list
        required: false
        fields:
          - label: Type
            name: linktype
            widget: select
            options:
              - Game Files
              - Other URL
          - label: "Location Name: i.e. ArtStation
...
ar363 commented 4 years ago

I think I know the cause of this error and how to reproduce it.

Cause: You have a list widget, probably

- label: Technologies and Skills
        name: techskills
        widget: list

and you have a few entries in which the value of the widget is in string format. For e.g. one of your prototype flie might have something like

techskills: xyz

instead of

techskills: [xyz]

i.e. string instead of list, and when netlifycms tries joining it (e.join() e which is supposed to be an array but turns out as a string), it gives out an error because your file had techskills stored as a string.

Reproducing the error: create a collection with a string widget, create an entry with the string filled in, and update the config file by changing the string widget to list, now when the entry is tried to open again, this error occours.

Fix: check wether e is an array before doing e.join()

if(e.isArray()){
e.join(',')
}
kitella1 commented 4 years ago

I've been offline for a while so did not get any of the notifications for this. I believe that your comment @ar363 is correct. If memory serves, I did have to redo my config.yml file and the issue was regarding the list widgets. My YAML now looks like this and works without issue:

collections:
  - name: "prototype"
    label: "Prototype"
    format: "json"
    folder: "content/prototypes"
    preview_path: "prototype/{{slug}}"
    create: true
    slug: "{{slug}}"
    editor:
      preview: false
    fields:
      - label: "Title"
        name: "title"
        widget: "string"
      - label: "Hero Image"
        name: "hero"
        widget: "image"
        allow_multiple: false
        required: false
      - label: "Year of Completion"
        name: "date"
        widget: "datetime"
        date_format: "YYYY"
      - label: "Technologies and Skills"
        name: "techskills"
        widget: "list"
        field: { label: "List Item", name: item, widget: string }
      - label: "High Concept"
        name: "highconcept"
        widget: "markdown"
      - label: "Video"
        name: "video"
        widget: "file"
        required: false
      - label: "Flowchart"
        name: "flowchart"
        widget: "code"
        required: false
        hint: "In the editor of your choice, export your diagrams as an iFrame. Untick any options for borders, editing, and layers."
      - label: "Description"
        name: "description"
        widget: "markdown"
      - label: "Supporting Document"
        name: "document"
        widget: "file"
        required: false
      - label: "Gallery Images"
        name: "gallery"
        widget: "list"
        required: false
        fields:
          - { label: "Image", name: "image", widget: "image" }
          - {
              label: "Image Description (For Screen Readers)",
              name: "alt",
              widget: "string",
            }
      - label: "External Links"
        name: "links"
        widget: "list"
        required: false
        fields:
          - {
              label: "Type",
              name: "linktype",
              widget: "select",
              options: ["Game Files", "Other URL"],
            }
          - {
              label: "Location Name: i.e. ArtStation, Steam",
              name: "linkname",
              widget: "string",
            }
          - { label: "Target", name: "linktarget", widget: "string" }
  - name: "desdoc"
    label: "Design Document"
    format: "json"
    folder: "content/design-documents"
    preview_path: "design/{{slug}}"
    create: true
    slug: "{{slug}}"
    editor:
      preview: false
    fields:
      - label: "Title"
        name: "title"
        widget: "string"
      - label: "Hero Image"
        name: "hero"
        widget: "image"
        allow_multiple: false
        required: false
      - label: "Year of Completion"
        name: "date"
        widget: "datetime"
        date_format: "YYYY"
      - label: "Technologies and Skills"
        name: "techskills"
        widget: "list"
        field: { label: "List Item", name: item, widget: string }
      - label: "Flowchart"
        name: "flowchart"
        widget: "code"
        required: false
        hint: "In the editor of your choice, export your diagrams as an iFrame. Untick any options for borders, editing, and layers."
      - label: "High Concept"
        name: "highconcept"
        widget: "markdown"
      - label: "Supporting Document"
        name: "document"
        widget: "file"
        required: false
      - label: "Description"
        name: "description"
        widget: "markdown"
      - label: "External Links"
        name: "links"
        widget: "list"
        required: false
        fields:
          - {
              label: "Type",
              name: "linktype",
              widget: "select",
              options: ["Game Files", "Other URL"],
            }
          - {
              label: "Location Name: i.e. ArtStation, Steam",
              name: "linkname",
              widget: "string",
            }
          - { label: "Target", name: "linktarget", widget: "string" }

Hopefully this helps someone else even though my issue has now been resolved

erezrokah commented 4 years ago

Closing this as a duplicate of https://github.com/netlify/netlify-cms/issues/3524