github-tools / github-tools/github

When writing a file: 422 (Unprocessable Entity)

Aperta
#631 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
3.8k
Fork
809
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hello,

I am trying to write a file doing:

```javascript
new GitHub(authPayload)
.getRepo(githubUsername, repoName)
.writeFile(null, path, content, commitMessage, {
encode: true,
author: null,
committer: null
})
```

But i am getting a `422 (Unprocessable Entity)`. This is a new file, and I am seeing in the log the `404 (Not Found)` from the call trying to get the SHA which is correct ( i dont understand why this is dumped into the console tho...).

Looking online at https://developer.github.com/v3/repos/contents/#create-or-update-file-contents , it seems that when `author` and `committer` are used , then we need to specify `name` and `author`. But in my case, I would like to use the default behavior which is to use the authenticated user.

When I look at http://github-tools.github.io/github/docs/3.2.3/Repository.js.html#line750 , it seems that the keys are set. Should they not be here at all, in case they are not given in the `option` payload ?

Thank you !

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start in Repository.js around line 750 and trace the writeFile call with a new file and the supplied options. Compare the generated author and committer payload with the GitHub Create or Update File Contents API documentation, and inspect how the missing-file SHA lookup handles its 404. Done means a new file can be written using the authenticated user without a 422 response.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.