concourse / github-release-resource

a resource for github releases
Apache License 2.0
57 stars 58 forks source link

Check failing against GH Enterprise with "error running command: Field 'databaseId' doesn't exist on type 'Release'" #109

Open OddBloke opened 3 years ago

OddBloke commented 3 years ago

We started seeing this today, presumably as a result of https://github.com/concourse/github-release-resource/blob/de55db24d0a22100d1bd69e663bbb2557bcd5e7b/github_graphql.go#L53 which was introduced in #107.

As even the latest pre-release of GHE doesn't include databaseId in its release GraphQL (per https://docs.github.com/en/enterprise-server@3.2/graphql/reference/objects#release), I expect that everyone else using this resource against GHE will also experience this issue.

OddBloke commented 3 years ago

(We've worked around this for now by pinning at the 1.6.3-alpine tag.)

kirillbilchenko commented 3 years ago

@OddBloke that's strange because I have a test which is not having databaseId in response from graphql, and it's not causing any issues there

OddBloke commented 3 years ago

That is strange! Let me know if there's any testing/debugging I can help you out with to try and figure it out.

kirillbilchenko commented 3 years ago

@OddBloke Maybe if you can share the response payload, it can help

OddBloke commented 3 years ago

I've just spent a bit of time putting together a Python script to do this, as the Go library doesn't appear to have a way to log the raw response. This is the query I'm running:

{
    repository(owner:"<REDACTED>",name:"<REDACTED>") {
        releases(first:10,after:null) {
            edges {
                node {
                    createdAt
                    publishedAt
                    id
                    isDraft
                    isPrerelease
                    name
                    tagName
                    url
                    databaseId
                }
            }
        }
    }
}

and this is the response I get:

{'errors': [{'extensions': {'code': 'undefinedField',
                            'fieldName': 'databaseId',
                            'typeName': 'Release'},
             'locations': [{'column': 21, 'line': 15}],
             'message': "Field 'databaseId' doesn't exist on type 'Release'",
             'path': ['query',
                      'repository',
                      'releases',
                      'edges',
                      'node',
                      'databaseId']}]}

If I remove databaseId from the query then I get a series of objects which look like this:

{
    "createdAt": "2021-08-05T15:17:37Z",
    "id": "MDc6UmVsZWFzZTExNTg=",
    "isDraft": false,
    "isPrerelease": false,
    "name": "v0.4.23",
    "publishedAt": "2021-08-05T16:03:30Z",
    "tagName": "v0.4.23",
    "url": "https://<REDACTED>/releases/tag/v0.4.23"
}
kirillbilchenko commented 3 years ago

I've just spent a bit of time putting together a Python script to do this, as the Go library doesn't appear to have a way to log the raw response. This is the query I'm running:

{
    repository(owner:"<REDACTED>",name:"<REDACTED>") {
        releases(first:10,after:null) {
            edges {
                node {
                    createdAt
                    publishedAt
                    id
                    isDraft
                    isPrerelease
                    name
                    tagName
                    url
                    databaseId
                }
            }
        }
    }
}

and this is the response I get:

{'errors': [{'extensions': {'code': 'undefinedField',
                            'fieldName': 'databaseId',
                            'typeName': 'Release'},
             'locations': [{'column': 21, 'line': 15}],
             'message': "Field 'databaseId' doesn't exist on type 'Release'",
             'path': ['query',
                      'repository',
                      'releases',
                      'edges',
                      'node',
                      'databaseId']}]}

If I remove databaseId from the query then I get a series of objects which look like this:

{
    "createdAt": "2021-08-05T15:17:37Z",
    "id": "MDc6UmVsZWFzZTExNTg=",
    "isDraft": false,
    "isPrerelease": false,
    "name": "v0.4.23",
    "publishedAt": "2021-08-05T16:03:30Z",
    "tagName": "v0.4.23",
    "url": "https://<REDACTED>/releases/tag/v0.4.23"
}

Thanks for provided the info, in this case, yes I see the reason, but maybe it makes sense to ask GitHub why it's so different in scope of mode, maybe they will answer something useful. In case if not, we will need to have two different models there for enterprise GitHub and for a public one.

OddBloke commented 2 years ago

Thanks for provided the info, in this case, yes I see the reason, but maybe it makes sense to ask GitHub why it's so different in scope of mode, maybe they will answer something useful. In case if not, we will need to have two different models there for enterprise GitHub and for a public one.

Unless GitHub revert the public API change, I think there will be supported GHE systems affected until at least June 2022 (3.1 EOL), and if they don't fix it in GHE before 3.2 goes out (and its already at the RC stage), at least a year from its release date. So I suspect, unfortunately, GitHub has stuck us with the need for two different models, at least in the interim.

OddBloke commented 2 years ago

The good news is that GHE 3.2 does now appear to have databaseId: https://docs.github.com/en/enterprise-server@3.2/graphql/reference/objects#release

So there will still be systems affected until June 2022, but that should be the point at which all supported GitHubs have it.