decaporg / decap-cms

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

New behavior on latest versions: Unable to create new pages w/ git-gateway and gitlab #2383

Closed unyo closed 5 years ago

unyo commented 5 years ago

Expected: Able to create new pages via netlify-cms when using a gitlab repository and git-gateway as the backend

Actual: Upon trying to create a new page, netlify-cms throws an error:

entries.js:592 TypeError: this.backend.unpublishedEntry is not a function
    at t.default.unpublishedEntry (implementation.js:502)
    at j.entryExist (backend.js:303)
    at j.generateUniqueSlug (backend.js:331)
    at j.persistEntry (backend.js:681)
    at entries.js:582
    at index.js:8
    at redux.js:462
    at Object.onPersist (Editor.js:102)
    at EditorInterface.js:147
    at Object.onSelection (Dropdown.js:85)

Applicable Versions: "gatsby-plugin-netlify": "^2.0.17", "gatsby-plugin-netlify-cms": "^4.0.2", "netlify-cms": "^2.9.2", "netlify-lambda": "^1.4.13",

CMS configuration

backend:
  name: git-gateway
  branch: master

Additional context

On this line:

https://github.com/netlify/netlify-cms/blame/0ce995d78c8123a32a3e9ef7117fd5386f3cd02d/packages/netlify-cms-core/src/backend.js#L266

this.interface.unpublishedEntries is always true since in git-gateway (below link) the function is always defined.

https://github.com/netlify/netlify-cms/blob/master/packages/netlify-cms-backend-git-gateway/src/implementation.js#L416

this.backend is either an instance of GitHubBackend or GitLabBackend, depending on whether it's gitlab or github.

https://github.com/netlify/netlify-cms/blob/master/packages/netlify-cms-backend-git-gateway/src/implementation.js#L416

Currently, only Github has a unpublishedEntries call: https://github.com/netlify/netlify-cms/blob/master/packages/netlify-cms-backend-github/src/implementation.js#L246

Whereas unpublishedEntries it is missing from Gitlab: https://github.com/netlify/netlify-cms/blob/master/packages/netlify-cms-backend-gitlab/src/implementation.js

And therefore when trying to create a new page, when trying to generateUniqueSlug, it'll fail with this.backend.unpublishedEntry is not a function since it doesn't exist in the instance of GitLabBackend.

erquhart commented 5 years ago

You're trying to use the editorial workflow with GitLab, which isn't supported yet. You can track the feature request here: https://github.com/netlify/netlify-cms/issues/568

That said, this should be caught at load time and the CMS should provide an error message in the UI and block login, so that should be fixed.

Sent with GitHawk

davidroberts63 commented 5 years ago

I'm seeing the exact same behavior. I had just created a new site and started noticing this. However I do not have the publish_mode set at all. Is there a default non-workflow value that people can use for that property? I'm also using gitlab.

erquhart commented 5 years ago

@davidroberts63 did you use a starter or add the CMS to an existing site?

Sent with GitHawk

unyo commented 5 years ago

@erquhart I don't have publish_mode: editorial_workflow set in my config.yml set, and when I tried setting it to publish_mode: simple it didn't seem to change the behavior of throwing TypeError: this.backend.unpublishedEntry is not a function. When I try to set it to publish_mode: editorial_workflow I get redirected to an error on the login page Error: The GitLab backend does not support the Editorial Workflow.

davidroberts63 commented 5 years ago

I've added it to an existing site. It's 11ty. I've done it with two other sites in the past.

The odd bit is that it can update an existing file just fine. Creating a new file is where the problem occurs.

I've double checked that I'm not using an older cashed version.

unyo commented 5 years ago

I'm trying to figure out which versions of netlify-cms + gatsby-plugin-netlify-cms work together properly.

gatsby-plugin-netlify-cms@latest is also throwing an error for me :( https://github.com/gatsbyjs/gatsby/issues/14794

TypeError: Cannot read property "minimizer" of undefined

I'm on the last legs of creating my 5th site with gatsby + netlify cms, and I've hit a stumbling block.

Edit: I was able to bring back the CMS functionality by falling back to netlify-cms@2.9.1 and gatsby-plugin-netlify-cms@4.0.1 👍

idiazroncero commented 5 years ago

I'm having the same exact problem:

Netlify: 2.9.2 Git repo: Gitlab

Not using Gatsby nor netlify-lambda, using 11ty as the static site builder.

My 11ty site was built with Eleventy CMS from the begining, and it always worked until this release.

Config.yml doesn't set a editorial_workflow and is as follows:

backend:
  name: git-gateway
  branch: master 

Can't publish new content, the entries.js:592 TypeError: this.backend.unpublishedEntry appear

idiazroncero commented 5 years ago

Tried resetting Gitlab token, to no avail. Only downgrading to 2.9.1 works.

talves commented 5 years ago

@unyo just a note, you should not be using netlify-cms with ^4.0 of gatsby-plugin-netlify-cms, you should use netlify-cms-app. and it looks like the minimizer issue has been resolved.

talves commented 5 years ago

@barthc can you see if this issue was introduced in #2139

jspizziri commented 5 years ago

Our project is in Hugo and is hosted on GitLab

Backend Config:

backend:
  name: git-gateway
  branch: master # Branch to update (optional; defaults to master)

Stack Trace:

entries.js:592 TypeError: this.backend.unpublishedEntry is not a function
    at t.default.unpublishedEntry (implementation.js:502)
    at j.entryExist (backend.js:303)
    at j.generateUniqueSlug (backend.js:331)
    at j.persistEntry (backend.js:681)
    at entries.js:582
    at index.js:8
    at redux.js:462
    at Object.onPersist (Editor.js:102)
    at EditorInterface.js:147
    at Object.onSelection (Dropdown.js:85)
barthc commented 5 years ago

@talves Yes #2139 introduced this issue, I will send in a PR to address the issue.