Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL error: Field 'stateReason' doesn't exist on type 'Issue' #11

Open
heckler opened this issue Jul 15, 2022 · 5 comments
Open

GraphQL error: Field 'stateReason' doesn't exist on type 'Issue' #11

heckler opened this issue Jul 15, 2022 · 5 comments

Comments

@heckler
Copy link

heckler commented Jul 15, 2022

Not sure whether this is dependent on server configuration or what, but when trying to get a digest for a repository on a Github Enterprise 3.3 instance, I'm getting this error about stateReason (full trace below)

Editing graphql\issue_frag.graphql and removing stateReason was enough to suppress the error;

Even though stateReason is used in templates\digest.html.j2, it's absense from the issue fragment does not seem to have caused any issues with the rendering of the template.

Error log

$ python3 -m dinghy https://some_private_instance.com/some_org/some_repo
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/__main__.py", line 7, in <module>
    cli(prog_name="dinghy")
  File "/home/vagrant/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/vagrant/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/vagrant/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vagrant/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/cli.py", line 53, in cli
    main_run(coro)
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/cli.py", line 21, in main_run
    return asyncio.run(coro)
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/digest.py", line 469, in make_digest
    results = await asyncio.gather(*coros)
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/digest.py", line 130, in get_repo_entries
    issue_container, pr_container = await asyncio.gather(
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/digest.py", line 152, in get_repo_issues
    repo, issues = await self.gql.nodes(
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/graphql_helpers.py", line 173, in nodes
    data = await self.execute(query, variables)
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/graphql_helpers.py", line 160, in execute
    _raise_if_error(data)
  File "/home/vagrant/.local/lib/python3.9/site-packages/dinghy/graphql_helpers.py", line 68, in _raise_if_error
    raise Exception(msg)
Exception: GraphQL error: Field 'stateReason' doesn't exist on type 'Issue' @fragment issueData.stateReason, line 47 column 3
@nedbat
Copy link
Owner

nedbat commented Jul 19, 2022

Thanks for trying this on GitHub Enterprise. I have no access to a similar installation, and don't know anything about it. Is version 3.3 the latest? I'm not even sure how to find information about the versions and what they support. The GraphQL docs don't say what version introduced stateReason. Do you have a way for me to find these things out? And then, how to conditionalize access? Or do I have to just require a certain minimum version of Enterprise?

@nedbat
Copy link
Owner

nedbat commented Jul 19, 2022

Thanks to your link in the other issue, I've found https://docs.github.com/en/[email protected]/graphql/reference/objects#issue, which does not mention stateReason. I wonder what other fields are missing? It looks like all of ProjectNext/ProjectV2 is also not available. Is it OK to simply ignore that on the theory that an Enterprise user wouldn't try to access a project URL anyway?

@heckler
Copy link
Author

heckler commented Jul 20, 2022

Is version 3.3 the latest?

It looks from the docs that 3.5 is the latest available, although the one I have access to is running on 3.3.7; unfortunately, since I don't manage the install, I'm limited to testing things against that version.

It looks like all of ProjectNext/ProjectV2 is also not available. Is it OK to simply ignore that on the theory that an Enterprise user wouldn't try to access a project URL anyway?

I did try briefly to organize a project for the list of repos I wanted to monitor, instead of using the YAML config, but I was not super impressed. I can't link a forked repo in a project (at least not on 3.3), and some of the repos I'm watching are forks. Also, I did ran into the issue with ProjectNext when trying to get a digest, so in the end I favored the YAML config :)

FWIIW, I'm perfectly fine with project queries not working - they might work fine on 3.4 or 3.5, I have no way of testing that right now.

@gkhays
Copy link

gkhays commented Dec 16, 2022

I'm running into the same issue. Our company uses GitHub Enterprise Server 3.5.8 whereas the docs say:

stateReason added to schema 2022-05-29

So stateReason is not yet available. I don't yet know enough about GraphQL to attempt a conditional query but I expect one could query the schema version and omit stateReason when not available.

Alternatively, I could add another YAML setting and it ignore stateReason if the new property is present.

Like @heckler I have removed stateReason from my local copy of issue_frag.graphql and am able to get it working that way.

Reference Links

@gkhays
Copy link

gkhays commented Dec 16, 2022

I'm beginning to see the problem... Since the issue fragment is never directly called from build_query any kind of conditional is exceedingly difficult. 😦

The best I could hope for would be to set a flag in the YAML so that when get_repo_issues is hit it would build a query with "repo_issues_crippled.graphql" which in turn would reference "issue_frag_crippled.graphql." Yuck! 😦

It seems I'll have to lobby our ops team to update to a more recent version of GHE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants