{"record":{"id":"3a45d7010e0d5618","repo":"mislav/hub","slug":"s-ngiven-up-after-retrying-for-1f-seconds","errorCode":null,"errorMessage":"%s\\nGiven up after retrying for %.1f seconds.","messagePattern":"(.+?)\\\\nGiven up after retrying for %\\.1f seconds\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/pull_request.go","lineNumber":380,"sourceCode":"\t\t\t\tutils.Check(err)\n\t\t\t} else {\n\t\t\t\tretryAllowance = 9\n\t\t\t}\n\t\t}\n\n\t\tvar pr *github.PullRequest\n\t\tfor {\n\t\t\tpr, err = client.CreatePullRequest(baseProject, params)\n\t\t\tif err != nil && strings.Contains(err.Error(), `Invalid value for \"head\"`) {\n\t\t\t\tif retryAllowance > 0 {\n\t\t\t\t\tretryAllowance -= retryDelay\n\t\t\t\t\ttime.Sleep(time.Duration(retryDelay) * time.Second)\n\t\t\t\t\tretryDelay++\n\t\t\t\t\tnumRetries++\n\t\t\t\t} else {\n\t\t\t\t\tif numRetries > 0 {\n\t\t\t\t\t\tduration := time.Since(startedAt)\n\t\t\t\t\t\terr = fmt.Errorf(\"%s\\nGiven up after retrying for %.1f seconds.\", err, duration.Seconds())\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif err == nil {\n\t\t\tdefer messageBuilder.Cleanup()\n\t\t}\n\n\t\tutils.Check(err)\n\n\t\tpullRequestURL = pr.HTMLURL\n\n\t\tparams = map[string]interface{}{}\n\t\tflagPullRequestLabels := commaSeparated(args.Flag.AllValues(\"--labels\"))","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/pull_request.go#L362-L398","documentation":"When creating the pull request fails transiently (e.g. HTTP 422/5xx), gh retries with an increasing delay up to a retry limit. If the error persists after the retries are exhausted, the last error is wrapped with \"Given up after retrying for N seconds.\" and surfaced to the user.","triggerScenarios":"The GitHub API call to create the PR keeps failing through all retry iterations: err != nil and (no more retries allowed), so the loop breaks after wrapping the error with the elapsed time since startedAt.","commonSituations":"PR already exists (422 unprocessable entity); GitHub API outage or rate limiting; slow/unreliable network causing repeated timeouts across the whole retry window.","solutions":["Read the wrapped original error: if it says a PR already exists, open the existing PR instead of creating a new one.","Wait for rate limits/outage to clear (check https://www.githubstatus.com) and retry later.","Check network/proxy stability; rerun the command once the connection is reliable.","Increase patience or check `gh auth status` — an invalid token can also produce persistent API failures."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := createPullRequest(...)\nif err != nil {\n    if strings.Contains(err.Error(), \"already exists\") {\n        // open existing PR instead\n    } else if strings.Contains(err.Error(), \"Given up after retrying\") {\n        // check network / API status, wait, retry later\n    }\n}","preventionTips":["Check for an existing PR before creating.","Handle rate limits and API outages before scripted runs.","Use a stable network/auth setup (gh auth status)."],"tags":["network","api","retry","pull-request"],"backgroundTag":"api-retries-exhausted","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}