Describe the bug
I am getting an error when I try to save some changes in the CMS of a site deployed on Netlify.
The error I get when I make a change and click the Save button is this: Failed to persist entry: API_ERROR: Reference update failed
To use GitHub as the authentication method for the CMS (so that my GitHub user can login into the CMS), I followed the instructions of the docs. The configuration can be seen here: https://github.com/Petrolog-IT/one-click-hugo-cms/blob/master/site/static/admin/config.yml
backend:
name: github
repo: Petrolog-IT/one-click-hugo-cms
branch: master
As the docs mentioned, I created an OAuth app on GitHub and added the Client ID and Secret in the appropriate settings page of Netlify:

I can login into the CMS of the site deployed on Netlify with the Petrolog-IT GitHub user successfully. I can also delete things from the CMS successfully. But I cannot save any changes.
To Reproduce
Expected behavior
Create a commit with the changes.
Screenshots

Applicable Versions:
CMS configuration
https://github.com/Petrolog-IT/one-click-hugo-cms/blob/master/site/static/admin/config.yml
Additional context
These related issues didn't help:
Forked your repo and was able to save changes to existing entries as well as create new ones :/
I also managed to do it through a different profile on GitHub, but for some reason it doesn't work with this account.
Having the same issue. I can save entries if i disable the editorial workflow though
I am seeing the same exact issue (i.e., UNPUBLISHED_ENTRY_PERSIST_FAILURE). It works with no editorial workflow, but it fails when I enable it.
I am using version 2.10.2-beta.0, but I tried with 2.0.0 and experienced the same problem.
Any clues?
Hi @erquhart, would you be able to point out the possible cause for this problem?
This only happens with editorial_workflow, which I need because I am storing images (and others files) relative to the content.
My repo: https://github.com/jimmyangel/librorojoetv
Any help is greatly appreciated!
@Petrolog-IT I can't access the repo in the issue (is it private/deleted?). Also can you share your network traffic?
@jimmyangel Thank you for sharing the repo, do you mind sharing network traffic while getting the error?
Hi @erezrokah, here are the har capture and the console log:
prototipo-librorojoetv.netlify.com.har.txt
prototipo-librorojoetv.netlify.com-1577052063765.log
Thank you very much for your time!
Ricardo
@erezrokah looks like the github api can't create a ref like so refs/heads/cms/home/home the first home is the collection name and the second one is the slug.
This is solved by deleting the cms branch from the repo. I remember it from a previous issue. I'll check why having a branch with that name breaks editorial workflow
I tried creating a workflow branch that has collection name and slug the same, and got the same error. For example, collection like so:
collections:
- name: 'posts'
slug: '{{slug}}'
If I type posts on the identifier field so the slug matches the collection name, the error shows.
Let me check again as I tried the same thing and it worked
Update: see this pull request https://github.com/erezrokah/librorojoetv/pull/2
And traffic:

Yup, you are right it's a branch issue. I don't have a branch cms/posts/posts but I have branches like cms/posts/posts/some-other-string
This is a git restriction when creating branches.
You can easily reproduce locally by doing:
git branch cms
git branch cms/foo
In order to prevent such cases in the future we will need to change our branch naming scheme, possibly as a part of https://github.com/netlify/netlify-cms/issues/1669.
Closing this, @Petrolog-IT please re-open with a link to the repo+network traffic if issue persists.
@robinsingh-bw, @jimmyangel please comment if the workaround of deleting the cms branch doesn't work for you
I added this to the list of API_ERROR solutions and workarounds: https://github.com/netlify/netlify-cms/issues/2827
Hi @erezrokah, I deleted the cms branch and it is working like a charm!
You guys are awesome! Thank you very much for your help.
Happy holidays!
Most helpful comment
I added this to the list of API_ERROR solutions and workarounds: https://github.com/netlify/netlify-cms/issues/2827