github / github/gh-gei

Don't retry queries on NOT_FOUND errors

Open
#975 2 comments 0 reactions 0 assignees View on GitHub
task
Dominant language
C#
Stars
478
Forks
146
Avg merge
7d 21h
Merged PRs (30d)
2

Description

We have gotten complaints from users that the `generate-mannequins-csv` command takes to long to raise an error if an invalid org name is provided for `--github-target-org`. Based on the verbose logs, it seems we are retrying the query to find the organization 5 times before raising the error. @timrogers has suggested that retries be skipped for "NOT_FOUND" errors so the command can fail fast.

Verbose logs for context:

```
aliwojo@Alis-MBP-2 ~ % gh gei generate-mannequin-csv --github-target-org notavalidorg --verbose
[4:57 PM] [INFO] You are running the latest version of the gei CLI [v0.41]
[4:57 PM] [INFO] Generating CSV...
[4:57 PM] [INFO] GITHUB ORG: notavalidorg
[4:57 PM] [INFO] OUTPUT: ./mannequins.csv
[4:57 PM] [DEBUG] HTTP POST: https://api.github.com/graphql
[4:57 PM] [DEBUG] HTTP BODY: {"query":"query($login: String!) {organization(login: $login) { login, id, name } }","variables":{"login":"notavalidorg"}}
[4:57 PM] [DEBUG] GITHUB REQUEST ID: C18C:0E94:3421A:6D00D:64557BB3
[4:57 PM] [DEBUG] RESPONSE (OK): {"data":{"organization":null},"errors":[{"type":"NOT_FOUND","path":["organization"],"locations":[{"line":1,"column":25}],"message":"Could not resolve to an Organization with the login of 'notavalidorg'."}]}
[4:57 PM] [DEBUG] OctoshiftCLI.OctoshiftCliException: Could not resolve to an Organization with the login of 'notavalidorg'.
at OctoshiftCLI.Services.GithubClient.EnsureSuccessGraphQLResponse(JObject response)
at OctoshiftCLI.Services.GithubClient.PostGraphQLAsync(String url, Object body, Dictionary`2 customHeaders)
at OctoshiftCLI.Services.GithubApi.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
[4:57 PM] [DEBUG] Retrying...
[4:57 PM] [DEBUG] HTTP POST: https://api.github.com/graphql
[4:57 PM] [DEBUG] HTTP BODY: {"query":"query($login: String!) {organization(login: $login) { login, id, name } }","variables":{"login":"notavalidorg"}}
[4:57 PM] [DEBUG] GITHUB REQUEST ID: C18C:0E94:346D0:6D9EE:64557BB7
[4:57 PM] [DEBUG] RESPONSE (OK): {"data":{"organization":null},"errors":[{"type":"NOT_FOUND","path":["organization"],"locations":[{"line":1,"column":25}],"message":"Could not resolve to an Organization with the login of 'notavalidorg'."}]}
[4:57 PM] [DEBUG] OctoshiftCLI.OctoshiftCliException: Could not resolve to an Organization with the login of 'notavalidorg'.
at OctoshiftCLI.Services.GithubClient.EnsureSuccessGraphQLResponse(JObject response)
at OctoshiftCLI.Services.GithubClient.PostGraphQLAsync(String url, Object body, Dictionary`2 customHeaders)
at OctoshiftCLI.Services.GithubApi.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
[4:57 PM] [DEBUG] Retrying...
[4:57 PM] [DEBUG] HTTP POST: https://api.github.com/graphql
[4:57 PM] [DEBUG] HTTP BODY: {"query":"query($login: String!) {organization(login: $login) { login, id, name } }","variables":{"login":"notavalidorg"}}
[4:57 PM] [DEBUG] GITHUB REQUEST ID: C18C:0E94:34F32:6EB5B:64557BBF
[4:57 PM] [DEBUG] RESPONSE (OK): {"data":{"organization":null},"errors":[{"type":"NOT_FOUND","path":["organization"],"locations":[{"line":1,"column":25}],"message":"Could not resolve to an Organization with the login of 'notavalidorg'."}]}
[4:57 PM] [DEBUG] OctoshiftCLI.OctoshiftCliException: Could not resolve to an Organization with the login of 'notavalidorg'.
at OctoshiftCLI.Services.GithubClient.EnsureSuccessGraphQLResponse(JObject response)
at OctoshiftCLI.Services.GithubClient.PostGraphQLAsync(String url, Object body, Dictionary`2 customHeaders)
at OctoshiftCLI.Services.GithubApi.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
[4:57 PM] [DEBUG] Retrying...
[4:57 PM] [DEBUG] HTTP POST: https://api.github.com/graphql
[4:57 PM] [DEBUG] HTTP BODY: {"query":"query($login: String!) {organization(login: $login) { login, id, name } }","variables":{"login":"notavalidorg"}}
[4:57 PM] [DEBUG] GITHUB REQUEST ID: C18C:0E94:35C85:706EB:64557BCC
[4:57 PM] [DEBUG] RESPONSE (OK): {"data":{"organization":null},"errors":[{"type":"NOT_FOUND","path":["organization"],"locations":[{"line":1,"column":25}],"message":"Could not resolve to an Organization with the login of 'notavalidorg'."}]}
[4:57 PM] [DEBUG] OctoshiftCLI.OctoshiftCliException: Could not resolve to an Organization with the login of 'notavalidorg'.
at OctoshiftCLI.Services.GithubClient.EnsureSuccessGraphQLResponse(JObject response)
at OctoshiftCLI.Services.GithubClient.PostGraphQLAsync(String url, Object body, Dictionary`2 customHeaders)
at OctoshiftCLI.Services.GithubApi.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
[4:57 PM] [DEBUG] Retrying...
[4:57 PM] [DEBUG] HTTP POST: https://api.github.com/graphql
[4:57 PM] [DEBUG] HTTP BODY: {"query":"query($login: String!) {organization(login: $login) { login, id, name } }","variables":{"login":"notavalidorg"}}
[4:57 PM] [DEBUG] GITHUB REQUEST ID: C18C:0E94:36F2E:72D04:64557BDC
[4:57 PM] [DEBUG] RESPONSE (OK): {"data":{"organization":null},"errors":[{"type":"NOT_FOUND","path":["organization"],"locations":[{"line":1,"column":25}],"message":"Could not resolve to an Organization with the login of 'notavalidorg'."}]}
[4:57 PM] [DEBUG] OctoshiftCLI.OctoshiftCliException: Could not resolve to an Organization with the login of 'notavalidorg'.
at OctoshiftCLI.Services.GithubClient.EnsureSuccessGraphQLResponse(JObject response)
at OctoshiftCLI.Services.GithubClient.PostGraphQLAsync(String url, Object body, Dictionary`2 customHeaders)
at OctoshiftCLI.Services.GithubApi.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
[4:57 PM] [DEBUG] Retrying...
[4:58 PM] [DEBUG] HTTP POST: https://api.github.com/graphql
[4:58 PM] [DEBUG] HTTP BODY: {"query":"query($login: String!) {organization(login: $login) { login, id, name } }","variables":{"login":"notavalidorg"}}
[4:58 PM] [DEBUG] GITHUB REQUEST ID: C18C:0E94:3879E:75F82:64557BF0
[4:58 PM] [DEBUG] RESPONSE (OK): {"data":{"organization":null},"errors":[{"type":"NOT_FOUND","path":["organization"],"locations":[{"line":1,"column":25}],"message":"Could not resolve to an Organization with the login of 'notavalidorg'."}]}
[4:58 PM] [ERROR] OctoshiftCLI.OctoshiftCliException: Failed to lookup the Organization ID for organization 'notavalidorg'
---> OctoshiftCLI.OctoshiftCliException: Could not resolve to an Organization with the login of 'notavalidorg'.
at OctoshiftCLI.Services.GithubClient.EnsureSuccessGraphQLResponse(JObject response)
at OctoshiftCLI.Services.GithubClient.PostGraphQLAsync(String url, Object body, Dictionary`2 customHeaders)
at OctoshiftCLI.Services.GithubApi.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
at Polly.AsyncPolicy.ExecuteAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
at OctoshiftCLI.RetryPolicy.Retry[T](Func`1 func)
at OctoshiftCLI.Services.GithubApi.GetOrganizationId(String org)
--- End of inner exception stack trace ---
at OctoshiftCLI.Services.GithubApi.GetOrganizationId(String org)
at OctoshiftCLI.Handlers.GenerateMannequinCsvCommandHandler.Handle(GenerateMannequinCsvCommandArgs args)
at OctoshiftCLI.Extensions.CommandExtensions.<>c__DisplayClass1_0`3.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext )
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<b__0>d.MoveNext()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.