decaporg / decap-cms

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

Git Gateway can't commit to branches with special chars #950

Open Quicksaver opened 6 years ago

Quicksaver commented 6 years ago

BUG REPORT INFORMATION

- Do you want to request a feature or report a bug?

bug

- What is the current behavior?

Similar to #222, I cannot save changes to content when working on a branch with characters like "/" and "#" in its name. For instance, I can commit to https://github.com/Quicksaver/one-click-hugo-cms, but if I try to edit something in branch https://github.com/Quicksaver/one-click-hugo-cms/tree/foo/%23bar and save, it will error with "Failed to persist entry: API_ERROR: Branch not found".

The /.netlify/git/github/branches endpoint does list the branch correctly, so it seems like it's a problem when trying to fetch it as /.netlify/git/github/branches/foo%2F%23bar, returning a 404 in the latter case.

- If the current behavior is a bug, please provide the steps to reproduce.

- What is the expected behavior?

It should save just as well as it does for the master branch.

- Please mention your CMS, node.js, and operating system version.

CMS 1.0.2 and 1.0.3.

erquhart commented 6 years ago

Confirmed. @brycekahle any chance Git Gateway is decoding the branch name? If you could check the branch name being referenced in the call from Git Gateway to GitHub, I'm betting we'll see an unexpected transformation.

brycekahle commented 6 years ago

From the logs, it appears the request to the git gateway is not receiving the escaped branch name, so it is something upstream.

erquhart commented 6 years ago

@brycekahle looks like new info came up since your last comment, can you update if so?

brycekahle commented 6 years ago

I filed a ticket on the appropriate internal service. I don't know when it will get addressed, so in the meantime it would be best to avoid # in branch names. All other symbols should work.

bigredwill commented 6 years ago

I was getting this error while trying to save a change in the admin on a file with no special chars. It seems that having caps in the file name causes an error as well.

I fixed the issue by changing the filename manually in my repo from 2018-08-02-Adventure-Time.md -> 2018-08-02-adventure-time.md Note: I created this file manually, thus the naming discrepancy. This is my error, but could be useful for fixing this issue.

I'm using gatsby-plugin-netlify-cms@3.0.0-rc.1 which uses netlify-cms@^2.0.11

oliviachang29 commented 5 years ago

I was getting this error while trying to save a change in the admin on a file with no special chars. It seems that having caps in the file name causes an error as well.

I fixed the issue by changing the filename manually in my repo from 2018-08-02-Adventure-Time.md -> 2018-08-02-adventure-time.md Note: I created this file manually, thus the naming discrepancy. This is my error, but could be useful for fixing this issue.

I'm using gatsby-plugin-netlify-cms@3.0.0-rc.1 which uses netlify-cms@^2.0.11

This should be noted in the docs. Was giving me trouble as well.

erquhart commented 5 years ago

Agreed, we would definitely take a PR for that.

wommy commented 4 years ago

i believe i triggered this with: branch: technomad_11ty-template

bigredwill commented 4 years ago

@erquhart I can work on a PR to add this to the docs!

Do you want to assign me this issue?

erquhart commented 4 years ago

@bigredwill that would be great, thanks!

erquhart commented 4 years ago

Also, I don't think documentation will serve to resolve this issue, but it will definitely help! It needs a proper fix, and it looks like we haven't quite determined what's causing it. Initially it was thought that an upstream service was specifically choking on the # symbol, but it looks like other characters are causing it as well.