sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
862 stars 43 forks source link

`createCommitOnBranch` is null from GitHub GraphQL API #130

Closed waynevanson closed 5 months ago

waynevanson commented 5 months ago

When I click save, I'm met with "createCommitOnBranch is null".

This means the commit property on the graphql response for createCommitOnBranch is null: createCommitOnBranch.commit === null

If there's more information I can provide, please let me know :)

Here are the GraphQL API's

graphql.repository request (unminified) ```json { "query": " query { repository(owner: \"waynevanson\", name: \"waynevanson\") { ref(qualifiedName: \"main\") { target { oid } } } } ", "variables": {} } ```
graphql.repository response ```json { "data": { "repository": { "ref": { "target": { "oid": "cba2034871dcccc1f3c5cc3c7532fa575ff8c719" } } } } } ```

The second graphql call returns an error.

graphql.createCommitOnBranch request (unminified) ```json { "query": " mutation ($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { url } } } ", "variables": { "input": { "branch": { "repositoryNameWithOwner": "waynevanson/waynevanson", "branchName": "main" }, "expectedHeadOid": "cba2034871dcccc1f3c5cc3c7532fa575ff8c719", "fileChanges": { "additions": [ { "path": "/src/content/posts/title-of-post.md", "contents": "LS0tCnRpdGxlOiBUaXRsZSBvZiBwb3N0CnN1bW1hcnk6IFN1bW1hcnkgb2YgcG9zdAotLS0KQm9keSBvZiBwb3N0Cg==" } ], "deletions": [] }, "message": { "headline": "Create Posts “title-of-post”" } } } } ```
graphql.createCommitOnBranch response (error) ```json { "data": { "createCommitOnBranch": null }, "errors": [ { "type": "NOT_FOUND", "path": [ "createCommitOnBranch" ], "locations": [ { "line": 1, "column": 50 } ], "message": "A path was requested for deletion which does not exist as of commit oid `cba2034871dcccc1f3c5cc3c7532fa575ff8c719`" } ] } ```

Other sveltia related files.

admin/config.yml ```yaml backend: name: github branch: main repo: waynevanson/waynevanson media_folder: /src/media public_folder: /public collections: - name: posts label: Posts folder: /src/content/posts create: true fields: - label: Title name: title widget: string - label: Summary name: summary widget: string - label: Body name: body widget: markdown ```
example collection item ```md --- title: Hello summary: World --- ## I'm mark down, aren't I! How exciting! ```
admin/index.html ```html Content Manager ```
kyoshino commented 5 months ago

Thanks for the bug report, @waynevanson! I’ll take a look at what’s going on.

kyoshino commented 5 months ago

The error message doesn’t make sense, but found the cause. Your folder path unexpectedly starts with /. Removing the leading slash should solve the issue.

-folder: /src/content/posts
+folder: src/content/posts

I’ll update Sveltia CMS to remove the / anyway.

kyoshino commented 5 months ago

Just shipped v0.20.0 with a workaround.

waynevanson commented 5 months ago

Nice @kyoshino! DecapCMS handle this correctly, so the feature parity is nice.

Thanks for the help!