picgo422错误代码

刚刚在vscode中用picgo上传图片失败,提示检查网络或设置。起初真的以为是token到期了或是网络不通,确定了网络正常之后又检查了token,发现也在有效期。
于是下载了picgo的windows客户端上传同样的图片,发现还是上传失败。好在windows客户端可以查看日志详情。

20230322145558
报错日志如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2023-03-22 14:45:49 [PicGo INFO] Before transform 
2023-03-22 14:45:49 [PicGo INFO] Transforming... Current transformer is [path]
2023-03-22 14:45:49 [PicGo INFO] Before upload
2023-03-22 14:45:49 [PicGo INFO] beforeUploadPlugins: renameFn running
2023-03-22 14:45:49 [PicGo INFO] Uploading... Current uploader is [github]
2023-03-22 14:45:50 [PicGo WARN] failed
2023-03-22 14:45:50 [PicGo ERROR] {
"method": "PUT",
"url": "https://api.github.com/repos/miaoyanginfo/hexo-img/contents/img/aaa.png",
"statusCode": 422,
"message": "Request failed with status code 422",
"stack": {},
"response": {
"status": 422,
"statusCode": 422,
"body": {
"message": "Invalid request.\n\n\"sha\" wasn't supplied.",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-or-update-file-contents"
}
}
}

网上搜了一下422报错应该是上传的图片文件名和已有的图片重名了,然后修改了文件名之后windows客户端和vscode插件上传正常了。
水一篇文章记录一下,分享给有相同报错的朋友。