mwroffo/pantabot

Resolve error: http422 and UnhandledPromiseRejection for certain repos but not others.

Closed this issue · 4 comments

The following line throws:

(node:15156) UnhandledPromiseRejectionWarning: Error: 422 error making request post https://api.github.com/repos/mwroffo/pantabot/issues: "Unprocessable Entity"
at new ResponseError (C:\Users\mroffo\zowe\pantabot\node_modules\github-api\dist\components\Requestable.js:50:118)
at handler (C:\Users\mroffo\zowe\pantabot\node_modules\github-api\dist\components\Requestable.js:373:18)
at process._tickCallback (internal/process/next_tick.js:68:7)

{const Issue = gh.getIssues('mwroffo', 'pantabot');}

Issue object is a Requestable object, which encapsulates githubauth for some account, and for some reason mwroffo/pantabot and zowe/zlux but not zowe/file-transfer-app have an UnhandledPromiseRejection during the creation of the Issue object.

HTTP error codes 401, 404, 410, 422 have all been seen in a continuing investigation of this problem. Calling the github api using several different request modules including request, request-promise, and @octokit/rest all show authorization problems, even when passing a bearer token.

According to the github api wiki, 422 indicates invalid fields in the issue being submitted. I found that some repos return 422 and terminate the post, whereas other repos silently drop the invalid fields and return 201. Removing the offending invalid fields "assignees" and "labels" made postIssue work properly for any valid github org_or_user/repo. I demonstrated this to Nolan Rogers.

Strange: these errors do not appear when I use cURL. Try calling api.github directly with axios or request instead of github-api. That will tell whether this is a problem with github-api (and hopefully reveal more useful error messages).

Update: tests using python produce the same errors. I suspect that something is wrong with my github auth configuration – although I've confirmed that my username, password, and bearer token are correct. Perhaps api access is disabled somewhere and I need to enable it. I'll look into this tomorrow.