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

Can't create file via API #7152

Closed
2 of 7 tasks
strahe opened this issue Jun 7, 2019 · 6 comments · Fixed by #7324
Closed
2 of 7 tasks

Can't create file via API #7152

strahe opened this issue Jun 7, 2019 · 6 comments · Fixed by #7324
Labels
Milestone

Comments

@strahe
Copy link

strahe commented Jun 7, 2019

  • Gitea version (or commit ref): 1.8.2
  • Git version:
  • Operating system: linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

always: Error: Unprocessable Entity

Screenshots

s

s1

@nopjmp
Copy link

nopjmp commented Jun 7, 2019

Looks like you need to supply a message via the error message for the commit

// FileOptions options for all file APIs
type FileOptions struct {
// message (optional) for the commit of this file. if not supplied, a default message will be used
Message string `json:"message" binding:"Required"`
// branch (optional) to base this file from. if not given, the default branch is used
BranchName string `json:"branch"`
// new_branch (optional) will make a new branch from `branch` before creating the file
NewBranchName string `json:"new_branch"`
// `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
Author Identity `json:"author"`
Committer Identity `json:"committer"`
}
// CreateFileOptions options for creating files
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
type CreateFileOptions struct {
FileOptions
// content must be base64 encoded
// required: true
Content string `json:"content"`
}

@jolheiser
Copy link
Member

The comment says it is optional and mentions a default message, however I could not find anything to support that in the code.
Currently the message has no default, so it is correctly bound as required

@richmahn Looks like the comments were added in 43cf2f3#diff-ec0f0f34b75aa5b40d1a7e55251a9c35
Thoughts?

@nopjmp
Copy link

nopjmp commented Jun 7, 2019

the binding in the struct is "Required" so the json parser will return an error.

@richmahn
Copy link
Contributor

@jolheiser Interesting. I know I brought in the comments from another part of the code and guess that wasn't caught. Will see if message can be optional and will removed the required flag.

@richmahn
Copy link
Contributor

I'll work on fixing this.

@richmahn
Copy link
Contributor

Fixed in PR #7324

@lunny lunny added this to the 1.9.0 milestone Jun 29, 2019
zeripath pushed a commit that referenced this issue Jun 29, 2019
…ault message (#7324)

* Fixes #7152 - Allow create/update/delete message to be empty, use default message

* Linting fix

* Fix to delete integration tests
jeffliu27 pushed a commit to jeffliu27/gitea that referenced this issue Jul 18, 2019
… use default message (go-gitea#7324)

* Fixes go-gitea#7152 - Allow create/update/delete message to be empty, use default message

* Linting fix

* Fix to delete integration tests
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants