Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

Endpoint for Creating Pull Requests is Username-case-sensitive

According to https://happygitwithr.com/github-acct.html, usernames are treated as case-insensitive. However, when you create a POST request to an endpoint with the form https://api.github.com/repos/:user/:repo/pulls, capitalization of the base field in the JSON content of the request seems to matter. The following examples are taken from a dump using mitmdump and mitmproxy while submitting a pull request to that endpoint with a Python tool (bloom-release).

 

Example 1 (fails):

POST Request JSON content:

{
    "base": "master",
    "body": "<redacted>",
    "head": "jwhitleyastuff:branch",
    "title": "<redacted>"
}

Response JSON content (response code 422: Unprocessable Entity):

{
    "documentation_url": "https://developer.github.com/v3/pulls/#create-a-pull-request",
    "errors": [
        {
            "code": "invalid",
            "field": "head",
            "resource": "PullRequest"
        }
    ],
    "message": "Validation Failed"
}

Example 2 (succeeds):

POST Request JSON Content:

{
    "base": "master",
    "body": "<redacted>",
    "head": "JWhitleyAStuff:branch",
    "title": "<redacted>"
}

Response JSON content (response code 201: Created):

{
    "_links": {
        "comments": {
            "href": "https://api.github.com/repos/<redacted>"
        },
        "commits": {
            "href": "https://api.github.com/repos/<redacted>"
        },
        "html": {
            "href": "https://github.com/<redacted>/pull/<redacted>"
        },
        "issue": {
            "href": "https://api.github.com/repos/<redacted>/issues/<redacted>"
        },
        "review_comment": {
            "href": "https://api.github.com/repos/<redacted>/pulls/comments{/number}"
        },
        "review_comments": {
            "href": "https://api.github.com/repos/<redacted>/pulls/<redacted>/comments"
        },
        "self": {
            "href": "https://api.github.com/repos/<redacted>/pulls/<redacted>"
        },
        "statuses": {
            "href": "https://api.github.com/repos/<redacted>/statuses/<redacted>"
        }
    },
    "additions": 2,
    "assignee": null,
    "assignees": [],
    "author_association": "CONTRIBUTOR",
    "base": {
        "label": "<redacted>:master",
        "ref": "master",
        "repo": {
...
1 Reply
Highlighted
Commander Lvl 1
Message 2 of 2

Re: Endpoint for Creating Pull Requests is Username-case-sensitive

Hey! What you are pointing out is the intended behavior given that you are pointing to a branch name rather than the user name. In this case, it just so happens that the branch name includes the username (which can be case insensitive) but the branch is still case sensitive. 

 

See here: https://github.com/desktop/desktop/issues/5971#issuecomment-432136897 for a little more context. 



*Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!*