Forum Discussion

what-swag's avatar
what-swag
New Contributor
8 years ago

How can I access the errors from a github pull?

I created a github pull for my API but each time I save the request I get an email with an error.  Unfortunately it just tells me there was an error, it doesn't give me the error message it got from github, making it hard for me to figure out the error.

 

The github respository is private and owned by an organization.  I created a personal access token with the "repo" OAuth scope from a user that has read access to the needed repository.  

 

Github reports the path as Organization/Repository/Directory/swagger.json.   Since the form requested the owner and repository separately I assume the path should just be Directory/swagger.json, but I tried lots of alternatives.

 

Any ideas about how to see the error or how to fix the pull request.

 

3 Replies

  • Hi, I'm assuming you're using the GitHub push feature, and not the codegen synchronization from the "Manage Integration" options, correct?

     

    Please make sure you have access to your repository and your token is correct.  You can test it like such:

     

    curl -H "Authorization: token TOKEN" https://api.github.com/orgs/YOUR_ORG/repos

     

    where `TOKEN` is your personal access token, and `YOUR_ORG` is your organization.  If you can't see the results here, your token must be bad.

    • what-swag's avatar
      what-swag
      New Contributor

      Thanks for responding so quickly.  Yes you are correct:  I am using the GitHub push feature.  I can run the operation you suggested and I can also access the swagger file from my repository using.

       

      curl -H "Authorization: token TOKEN" https://api.github.com/repos/ORG/REPO/contents/DIR/MYAPI.json?ref=master

       

      Is there some other github operation that you try and perform that needs additional scope/permissions?  I created a GitHub user that has read-only access to the repository and I've created a token for that user with "repo" scope.   Could it be that you require "admin:repo_hook" scope and an admin user so you can set up a web hook to call you when the file is merged into the branch?  Is there a more secure way of handling this?   One way is to ask users to create their own repo hook using a curl command that you supply.  You can read how werker solved this problem here.

       

      Having admin access to your users' github repositories is a security liability that you probably want to avoid.

       

      In any case, reporting the github operation and the error in the email message is probably a nice idea.

       

      • fehguy's avatar
        fehguy
        Staff

        Hi, you do need write access to your repos because the integration has permission to save the swagger definition to it.  You do not need write access--the following should suffice:

         

         

        Give that a shot and let us know how it goes