Skip to content

Enable go-gh disk cache for repository features API calls - #50842

Merged
pelikhan merged 6 commits into
mainfrom
copilot/go-fan-go-module-review-again
Aug 6, 2026
Merged

Enable go-gh disk cache for repository features API calls#50842
pelikhan merged 6 commits into
mainfrom
copilot/go-fan-go-module-review-again

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The go-fan module review of github.com/cli/go-gh/v2 flagged that pkg/workflow/repository_features_validation.go only cached discussions/issues lookups in an in-process sync.Map, so every fresh gh-aw CLI invocation (e.g. repeated runs in the same CI workflow) re-queries the GitHub API for the same, rarely-changing repo settings — despite go-gh already shipping a disk-backed HTTP cache for this exact purpose.

Client construction

  • Replaced api.DefaultGraphQLClient() / api.DefaultRESTClient() (zero-value options) with api.NewGraphQLClient(...) / api.NewRESTClient(...) passing ClientOptions{EnableCache: true, CacheTTL: repositoryFeaturesCacheTTL} for the discussions-enabled and has-issues checks.
  • repositoryFeaturesCacheTTL set to 5 minutes — short enough to catch settings changes reasonably fast, long enough to meaningfully cut redundant calls.
  • The existing in-process sync.Map remains as a same-process fast path on top of this disk cache.
client, err := api.NewGraphQLClient(api.ClientOptions{
    EnableCache: true,
    CacheTTL:    repositoryFeaturesCacheTTL,
})

Documentation

  • Added a "Enable GitHub API Request Logging" section to the debugging guide documenting GH_DEBUG=api, which go-gh already honors for verbose request/response logging with no extra wiring — useful for troubleshooting instead of reaching for custom instrumentation.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 16.9 AIC · ⊞ 5.9K ·
Comment /souschef to run again

Copilot AI linked an issue Aug 6, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits August 6, 2026 12:26
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Review go-gh module usage in gh-aw Enable go-gh disk cache for repository features API calls Aug 6, 2026
Copilot AI requested a review from pelikhan August 6, 2026 12:34
@pelikhan
pelikhan marked this pull request as ready for review August 6, 2026 12:41
Copilot AI balanced review requested due to automatic review settings August 6, 2026 12:41
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Test Quality Sentinel: No new or modified test functions in this PR. Only a comment update in existing test file. Existing integration tests provide adequate coverage for the production code changes (disk cache enablement for go-gh API clients). No test quality action required.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (24 additions detected, threshold is 100).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

The changes are correct and well-structured:

  • Replacing DefaultGraphQLClient/DefaultRESTClient with NewGraphQLClient/NewRESTClient using EnableCache: true and a 5-minute TTL is the correct go-gh pattern for cross-invocation HTTP caching.
  • The existing sync.Map in-process cache is preserved as a fast path on top of the disk cache.
  • 5-minute TTL is a sensible balance for rarely-changing repo settings.
  • The GH_DEBUG=api documentation addition is accurate and useful.

No blocking issues found.> [!WARNING]

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 16 AIC · ⊞ 5.3K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Skills-Based Review

Applied /tdd and /codebase-design — approving with one minor suggestion on test symmetry.

📋 Summary

What the PR does well

  • Clean two-layer caching: in-process sync.Map + go-gh disk-backed HTTP cache is a well-reasoned design that doesn't break the existing fast path.
  • Minimal surface change: only the client construction sites are touched; all validation logic is untouched.
  • Well-commented: the new repositoryFeaturesCacheTTL constant and inline comments clearly explain the trade-off.
  • Symmetric REST & GraphQL treatment: both checkRepositoryHasIssuesUncached and checkRepositoryHasDiscussionsUncached get the same EnableCache: true, CacheTTL: repositoryFeaturesCacheTTL options.
  • Good TTL choice: 5 minutes is short enough to catch settings changes in CI, long enough to save API calls across repeated steps.

One suggestion

checkRepositoryHasDiscussionsUncached has no dedicated uncached test, while checkRepositoryHasIssuesUncached does — see inline comment. This is a minor gap but easy to close.

> 🧠 *Reviewed using Matt Pocock's skills by [Matt Pocock Skills Reviewer](https://github.com/github/gh-aw/actions/runs/31102470123)* · sonnet46 · 27.7 AIC · ⊞ 7.1K > Comment /matt to run again

func TestCheckRepositoryHasIssuesUncached(t *testing.T) {
// Test the REST client code path directly
// This test exercises the api.DefaultRESTClient() and client.Get() path
// This test exercises the api.NewRESTClient() (with disk cache enabled) and client.Get() path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] checkRepositoryHasDiscussionsUncached has no dedicated uncached test — this PR changed both uncached functions symmetrically, but only the REST path has a direct unit test.

💡 Suggested addition

A mirror of TestCheckRepositoryHasIssuesUncached would close the gap:

func TestCheckRepositoryHasDiscussionsUncached(t *testing.T) {
	repo := "github/gh-aw"
	_, err := checkRepositoryHasDiscussionsUncached(repo)
	if err != nil {
		t.Logf("checkRepositoryHasDiscussionsUncached failed (may be auth issue): %v", err)
		return
	}
}

This keeps coverage symmetric and ensures the GraphQL client construction path (including EnableCache) is exercised the same way as the REST path.

@copilot please address this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables go-gh’s five-minute disk cache for repository feature checks across CLI invocations.

Changes:

  • Enables caching for discussions and issues API clients.
  • Updates related test commentary and API debugging documentation.
  • Adds designer mappings to the workflow skill router.
Show a summary per file
File Description
pkg/workflow/repository_features_validation.go Configures cached REST and GraphQL clients.
pkg/workflow/repository_features_validation_test.go Updates REST client test commentary.
docs/src/content/docs/troubleshooting/debugging.md Documents GH_DEBUG=api.
.github/skills/agentic-workflows/SKILL.md Adds the designer mappings prompt.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Suppressed comments (1)

pkg/workflow/repository_features_validation.go:326

  • This now performs disk-backed caching, but the function header still describes checkRepositoryHasIssuesUncached as using “no caching.” Clarify that only the process-level cache is bypassed.
	// Create REST client. EnableCache persists the (rarely-changing) has-issues lookup to
	// go-gh's disk-backed HTTP cache so repeated CLI invocations don't re-query the API.
  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Balanced

Comment on lines +290 to +293
client, err := api.NewGraphQLClient(api.ClientOptions{
EnableCache: true,
CacheTTL: repositoryFeaturesCacheTTL,
})
Comment on lines +288 to +289
// EnableCache persists the (rarely-changing) discussions-enabled lookup to go-gh's
// disk-backed HTTP cache so repeated CLI invocations don't re-query the API.

### Enable GitHub API Request Logging

`gh aw` uses go-gh's native REST/GraphQL clients for all GitHub API calls. Setting `GH_DEBUG=api` prints verbose request/response details for those calls to stderr, with no extra flags needed:
func TestCheckRepositoryHasIssuesUncached(t *testing.T) {
// Test the REST client code path directly
// This test exercises the api.DefaultRESTClient() and client.Get() path
// This test exercises the api.NewRESTClient() (with disk cache enabled) and client.Get() path
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🧪 Test Quality Sentinel Analysis

PR: #50842 — Enable go-gh disk cache for repository features API calls
Status: ✅ No test quality action needed

Summary

This PR contains no new test functions and no test behavior modifications. The only change to test files is a single comment update in TestCheckRepositoryHasIssuesUncached():

  • File: pkg/workflow/repository_features_validation_test.go
  • Change: Comment documentation update reflecting the production code change from api.DefaultRESTClient() to api.NewRESTClient(api.ClientOptions{EnableCache: true, CacheTTL: 5m})
  • Behavioral Tests Modified: 0
  • New Tests Added: 0

Production Code Coverage

The production changes (pkg/workflow/repository_features_validation.go: +23/-4 lines) include:

  • Enabling go-gh's disk-backed HTTP cache for repository feature lookups (discussions/issues)
  • Configuring CacheTTL: 5 * time.Minute for cache expiration
  • Refactoring client construction to use api.NewGraphQLClient() and api.NewRESTClient() with explicit ClientOptions

These changes are exercised by existing integration tests (marked //go:build integration), including:

  • TestCheckRepositoryHasIssuesUncached() — tests the REST client path directly
  • TestCheckRepositoryHasIssuesWithCaching() — tests caching correctness
  • TestCheckRepositoryHasDiscussions() — tests GraphQL client path

Verdict: Existing test coverage is sufficient. No test quality concerns.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 22.8 AIC · ⊞ 7.7K ·
Comment /review to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot Please address the unresolved review threads (newest first):

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.5 AIC · ⊞ 8.3K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

[!WARNING]
Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

...

Addressed the unresolved Copilot reviewer threads in commit 8a74e34d88:

  • added deterministic two-client disk-cache tests for GraphQL and REST repository-feature checks
  • clarified uncached function comments to distinguish process cache vs go-gh disk cache
  • scoped GH_DEBUG=api docs text to go-gh client calls

I also investigated the cited failed jobs and pulled logs: the agent run did not show a code/security finding in the provided tail, and Unit tests (D-L) failed in pkg/cli with package-level failure output that appears unrelated to these workflow-cache changes.

Copilot AI requested a review from gh-aw-bot August 6, 2026 13:45
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot Please verify the previously answered review feedback is fully resolved, close any remaining unresolved review threads, investigate the failed checks below, refresh the branch if needed, and then run the pr-finisher skill.
Failed checks to investigate:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 16.9 AIC · ⊞ 5.9K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

[!WARNING]
Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

...

Addressed and pushed in a9ff94548c.

  • Verified prior Copilot feedback remains resolved in code/tests.
  • Investigated failed checks from run 31103223090 and reproduced locally.
  • Fixed both reproduced failures:
    • synced pkg/cli/data/agentic_workflows_fallback_aw_files.json with .github/aw/*.md
    • re-synced OTLP WIF script headers between actions/setup/js/... and pkg/workflow/js/...
  • Also fixed a coupled regression in checkRepositoryHasDiscussionsUncached/checkRepositoryHasIssuesUncached by validating owner/repo format before client construction, restoring expected format-error behavior.
  • Re-ran targeted tests and make agent-report-progress successfully.

I can’t directly mark all review threads resolved from this environment, but all actionable items I could address in code are now applied in the commit above.

@pelikhan
pelikhan merged commit d8afbc8 into main Aug 6, 2026
@pelikhan
pelikhan deleted the copilot/go-fan-go-module-review-again branch August 6, 2026 14:49
Copilot stopped work on behalf of gh-aw-bot due to an error August 6, 2026 14:49
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go-fan] Go Module Review: go-gh

4 participants