8000 breaks with older github enterprise versions · Issue #794 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content
breaks with older github enterprise versions #794
Closed
@electrofelix

Description

@electrofelix

Typically Github Enterprise is lagging keywords in the responses that are seen from github.com. Currently seeing the following error on trying to use this library with a local GitHub Enterprise instance.

IncompleteResponse [The library was expecting more data in the response (KeyError(u'license',)). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.]

Thrown by a call to (github3.enterprise_login()).repository()

Patching the library to deal with this issue only results in seeing another issue:

IncompleteResponse: None The library was expecting more data in the response (KeyError(u'plan',)). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.

Thrown by a call to (github3.enterprise_login()).me()

In both cases my token had full access, just that the public Github is returning more than the private versions.

One solution would be to update

try:
ret = response.json()
except ValueError:
raise exceptions.UnexpectedResponse(response)
to use something like the following:

        ret = collections.defaultdict(lambda: None)
        try:
            ret.update(response.json())
        except ValueError:
            raise exceptions.UnexpectedResponse(response)

But that would also require updating locations such as

self.plan = Plan(user['plan'], self)
to check if the value was not None before trying to use as an argument to create an object:

        if user['plan'] is not None:
            self.plan = Plan(user['plan'], self)
        else:
            self.plan = None

That would mean looking through each definition of _update_attributes() and modifying to test for None where the result of dictionary lookup was used to create an object.

This would certainly allow the library to work across a wide range of Github Enterprise releases, as well as simply returning None for certain data items when users scope tokens to have less permissions.

If this seems reasonable I can put together a PR to do the needful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0