{"record":{"id":"6df5103ae6105144","repo":"cilium/cilium","slug":"creating-github-client-w","errorCode":null,"errorMessage":"creating github client: %w","messagePattern":"creating github client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cilium-cli/features/summary.go","lineNumber":63,"sourceCode":"\treturn s.printSummaryFromJsons(workflowData)\n}\n\nfunc (s *Feature) downloadWorkflowData(ctx context.Context) error {\n\ttoken := os.Getenv(\"GITHUB_TOKEN\")\n\n\tif token == \"\" {\n\t\treturn fmt.Errorf(\"GITHUB_TOKEN environment variable must be set.\")\n\t}\n\n\tparts := strings.Split(s.params.Repo, \"/\")\n\tif len(parts) != 2 {\n\t\treturn fmt.Errorf(\"invalid repository format. Expected 'owner/repo', got '%s'\", s.params.Repo)\n\t}\n\towner, repoName := parts[0], parts[1]\n\n\tghClient, err := github.NewClient(github.WithAuthToken(token))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating github client: %w\", err)\n\t}\n\n\tallRuns := map[int64]*github.WorkflowRun{}\n\t// Fetch workflow runs for the specific commit\n\tfor _, event := range []string{\"push\", \"schedule\", \"pull_request\", \"pull_request_target\"} {\n\t\topts := &github.ListWorkflowRunsOptions{\n\t\t\tHeadSHA: s.params.Commit,\n\t\t\tStatus:  \"completed\",\n\t\t\tEvent:   event,\n\t\t\tListOptions: github.ListOptions{\n\t\t\t\tPerPage: 100,\n\t\t\t},\n\t\t}\n\n\t\tfor {\n\t\t\truns, resp, err := ghClient.Actions.ListRepositoryWorkflowRuns(ctx, owner, repoName, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to fetch workflow runs: %w\", err)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/cilium-cli/features/summary.go#L45-L81","documentation":" `github.NewClient(github.WithAuthToken(token))` (go-github) returned an error while constructing the authenticated client in `downloadWorkflowData`. This is rare — it generally means the auth credential itself was rejected at construction time (e.g. invalid token string) rather than an API/network problem.","triggerScenarios":" github.NewClient with WithAuthToken(token) fails on the supplied GITHUB_TOKEN value, e.g. malformed or control-character-containing token string.","commonSituations":" Token pasted with stray whitespace/newlines or quotes from a misconfigured secret; empty-but-set token corner cases; incompatible token format for the client version.","solutions":["Re-export GITHUB_TOKEN from a trusted source without surrounding quotes/whitespace: `export GITHUB_TOKEN=$(gh auth token)`","Regenerate the token and confirm it is a valid GitHub token format","If using a fine-grained/App token, verify the go-github version supports it and upgrade dependencies if needed"],"exampleFix":"// before\nexport GITHUB_TOKEN=\" ghp_xxx\\n\"\n// after\nexport GITHUB_TOKEN=$(gh auth token)","handlingStrategy":"validation","validationCode":"token := os.Getenv(\"GITHUB_TOKEN\")\ntoken = strings.TrimSpace(token)\nif token == \"\" || strings.ContainsAny(token, \"\\n\\r\\x00\") ||\n\t!(strings.HasPrefix(token, \"ghp_\") || strings.HasPrefix(token, \"github_pat_\") || strings.HasPrefix(token, \"ghs_\")) {\n\treturn errors.New(\"GITHUB_TOKEN is not a valid GitHub token string\")\n}","typeGuard":"func validTokenFormat(t string) bool {\n\tt = strings.TrimSpace(t)\n\treturn len(t) > 20 && !strings.ContainsAny(t, \" \\n\\r\\t\\x00\")\n}","tryCatchPattern":"err := feat.GenSummary(ctx)\nif err != nil && strings.Contains(err.Error(), \"creating github client\") {\n\treturn fmt.Errorf(\"re-check GITHUB_TOKEN contents (quotes/whitespace?): %w\", err)\n}","preventionTips":["Trim and re-export the token without surrounding quotes or newlines","Regenerate the token if its format looks malformed","Verify the secret value in CI by checking only its length, never logging it"],"tags":["github","client","token"],"backgroundTag":"invalid-credentials","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}