Skip to content

Commit

Permalink
More explicit error message when Field Suggestion is (partially) disa…
Browse files Browse the repository at this point in the history
…bled (#73)
  • Loading branch information
iCarossio authored Jul 10, 2023
1 parent 2267f63 commit 30e2509
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ LOG_LEVEL=`INFO` # A string level for logging.

> Due to time constraints @nikitastupin won't be able to answer all the issues for some time but he'll do his best to review & merge PRs
In case of question or issue with clairvoyance please refer to [wiki](https://github.com/nikitastupin/clairvoyance/wiki) or [issues](https://github.com/nikitastupin/clairvoyance/issues). If this doesn't solve your problem feel free to open a [new issue](https://github.com/nikitastupin/clairvoyance/issues/new).
In case of questions or issues with Clairvoyance please refer to [wiki](https://github.com/nikitastupin/clairvoyance/wiki) or [issues](https://github.com/nikitastupin/clairvoyance/issues). If this doesn't solve your problem feel free to open a [new issue](https://github.com/nikitastupin/clairvoyance/issues/new).

## Contributing

Expand Down
15 changes: 11 additions & 4 deletions clairvoyance/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ async def __probation(document: str) -> Optional[graphql.TypeRef]:

if not typeref and context != FuzzingContext.ARGUMENT:
try:
raise Exception(f'Unable to get TypeRef for {documents} in context {context}')
raise Exception(f"""Unable to get TypeRef for {documents} in context {context}.
It is very likely that Field Suggestion is not fully enabled on this endpoint.""")
except Exception as e:
raise Exception(e) from e

Expand Down Expand Up @@ -467,8 +468,9 @@ async def probe_typename(input_document: str) -> str:

response = await client().post(document=document)
if 'errors' not in response:
log().debug(f'Unable to get typename from {document}')
sys.exit(1)
log().warning(f"""Unable to get typename from {document}.
Field Suggestion might not be enabled on this endpoint. Using default "Query""")
return 'Query'

errors = response['errors']

Expand All @@ -482,7 +484,9 @@ async def probe_typename(input_document: str) -> str:
break

if not match:
log().debug(f'Unkwon error in `probe_typename`: "{errors}" does not match any known regexes.')
log().debug(f"""Unkwon error in `probe_typename`: "{errors}" does not match any known regexes.
Field Suggestion might not be enabled on this endpoint. Using default "Query""")
return 'Query'

return (match.group('typename').replace('[', '').replace(']', '').replace('!', ''))

Expand Down Expand Up @@ -555,6 +559,9 @@ async def clairvoyance(
input_document: str,
input_schema: Dict[str, Any] = None,
) -> str:

log().debug(f'input_document = {input_document}')

if not input_schema:
root_typenames = await fetch_root_typenames()
schema = graphql.Schema(
Expand Down

0 comments on commit 30e2509

Please sign in to comment.