Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'path') #5815

Closed
dara-icf opened this issue Sep 16, 2021 · 10 comments
Closed

TypeError: Cannot read properties of undefined (reading 'path') #5815

dara-icf opened this issue Sep 16, 2021 · 10 comments

Comments

@dara-icf
Copy link

Describe the bug

To Reproduce

Expected behavior

Screenshots

Applicable Versions:

  • Netlify CMS version: netlify-cms@2.10.164
  • Git provider: github
  • Browser version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36

CMS configuration

backend:
  name: github
  repo: ux-at-icfnext/practice-netlify-cms
  "netlify.configure({'site_id'": gifted-boyd-d36ba9.netlify.com});
media_folder: assets/img/uploads
collections:
  - label: Posts
    name: posts
    folder: _posts
    create: true
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    fields:
      - label: Layout
        name: layout
        widget: hidden
        default: default
      - label: Title
        name: title
        widget: string
      - label: Description
        name: desc
        widget: string
      - label: Body
        name: body
        widget: markdown
    publish: true
    type: folder_based_collection
    sortable_fields:
      - commit_date
      - title
      - commit_author
    view_filters: []
    view_groups: []
publish_mode: simple
slug:
  encoding: unicode
  clean_accents: false
  sanitize_replacement: "-"
public_folder: /assets/img/uploads
isFetching: false
error: null

Additional context

@bytrangle
Copy link
Collaborator

Hello @dara-icf . Can you provide the steps of actions that lead to the TypeError issue?

@gangsthub
Copy link
Contributor

gangsthub commented Sep 24, 2021

This happened to me. Fresh install. I couldn't upload content or media files. I tried uploading an image to isolate the issue And looking at the error messages I found that Netlify CMS was trying to save in my repository in the master branch, But I only had a main branch. Quick and dirty solution was to create the master branch and go back to use it by default. Following these steps but changing "main" for "master" 😢:

https://stevenmortimer.com/5-steps-to-change-github-default-branch-from-master-to-main/

I also triggered a new deploy to see if it was doing the "checkout" correctly:
image

@bytrangle
Copy link
Collaborator

bytrangle commented Sep 24, 2021

@gangsthub : Do you mean that this error stems from Netlify CMS trying to push content to a master branch that doesn't exist?
Actually, it's a known issue for while #5617 and I'm actively working on fixing it. It's not complicated, but there's already a large backlog of PRs to review so it will take a while.

But I'm not sure if that is the sole cause of this issue. Last time I encountered this problem, Netlify CMS will display this error: "API_ERROR: Branch not found".

Do you mind providing a step by step and your config file?

@gangsthub
Copy link
Contributor

I'll try to come up with a repro guide, but I can't promise anything. The only thing I know is that it got fixed after I did the branches change. 🙏🏽

@bytrangle
Copy link
Collaborator

@gangsthub : The issue will always get resolved if you specify the branch name in the config. Actually, it only manifests when you don't configure branch name, which I think is the case with many newly-initiated project with Netlify CMS.

What happens under the hood is that Netlify CMS will assume that your default branch is master, which is no longer the case with all the major Git host. Then, when it tried to push content to master branch, it will get hit with an 404 (IIRC) error because master doesn't exist in many repos.

So, that's the gist of the problem 😓.

@dara-icf
Copy link
Author

dara-icf commented Sep 27, 2021 via email

@bytrangle
Copy link
Collaborator

@dara-icf So is it okay to close this issue now?

@gangsthub
Copy link
Contributor

Thanks, @bytrangle! I forgot about that branch option in the configuration!

@bytrangle
Copy link
Collaborator

@gangsthub Many of us got tripped by that when first setting up Netlify CMS :).

@dara-icf
Copy link
Author

dara-icf commented Sep 28, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants