Skip to content

fix(scm-github): throttle repeated GitHub ETag network warnings#1554

Open
ChiragArora31 wants to merge 5 commits into
AgentWrapper:mainfrom
ChiragArora31:fix/1526-etag-network-warning-throttle
Open

fix(scm-github): throttle repeated GitHub ETag network warnings#1554
ChiragArora31 wants to merge 5 commits into
AgentWrapper:mainfrom
ChiragArora31:fix/1526-etag-network-warning-throttle

Conversation

@ChiragArora31

Copy link
Copy Markdown
Contributor

Resolves #1526.

Summary

  • Suppresses repeated transient network warnings from GitHub ETag guard checks per guard/cache key.
  • Clears suppression after a successful guard response so future outages still log once.

Root cause

When gh api repeatedly failed for transient connectivity reasons, every poll emitted the same warning even though the fallback behavior was already safe.

Approach

Classify common transient network messages, remember which guard/key has already warned, and reset that memory on successful 200/304 responses. Non-transient failures keep logging every time.

Verification

  • pnpm --filter @aoagents/ao-plugin-scm-github test -- graphql-batch.test.ts
  • pnpm --filter @aoagents/ao-plugin-scm-github typecheck
  • pnpm --filter @aoagents/ao-plugin-scm-github test

@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a per-guard/per-cache-key transient-warning throttle for the three GitHub ETag guards in graphql-batch.ts. When a network error matches a known transient pattern, only the first failure for a given guard+key pair is logged; subsequent identical failures are suppressed until a successful 200 or 304 response clears the key. All three guards and every success/304 path (including catch-path 304s) were updated in this version.

  • Adds TRANSIENT_NETWORK_PATTERNS, a module-level transientNetworkWarningKeys Set, and helpers warnETagGuardFailure / markETagGuardSuccess / pruneTransientNetworkWarningKeys to manage suppression state.
  • Updates Guards 1, 2, and 3 to route failures through warnETagGuardFailure and to call markETagGuardSuccess on every normal success and on every 304 path (both try-path and catch-path).
  • Adds targeted tests covering: first-warning emission, repeated suppression, recovery on catch-path 304, and pass-through of non-transient errors.

Confidence Score: 5/5

Safe to merge — all three ETag guards are consistently updated, every 304 and success path clears the suppression key, and the fallback behavior is preserved on every error path.

The change is purely additive observability throttling. Suppression only affects logging, never the returned boolean, so data correctness cannot regress. All catch-path 304 branches now call markETagGuardSuccess, Guard 3 is fully wired up, duplicate imports in the test file are gone, and clearETagCache resets the new Set.

No files require special attention.

Important Files Changed

Filename Overview
packages/plugins/scm-github/src/graphql-batch.ts Adds throttling helpers and wires them into all three ETag guards; all catch-path 304 branches now call markETagGuardSuccess, and clearETagCache clears the suppression set. Previously flagged gaps are resolved.
packages/plugins/scm-github/test/graphql-batch.test.ts Adds Guard 1, 2, and 3 throttling tests covering suppression, recovery via catch-path 304, and non-transient pass-through; imports are clean with no duplicates.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ETag Guard call] --> B{execGhAsync success?}
    B -- Yes, 304 --> C[markETagGuardSuccess\nclear suppression key]
    B -- Yes, 200 --> C
    C --> D[return result]
    B -- Error --> E[extractErrorOutput]
    E --> F{is304 in output?}
    F -- Yes --> C
    F -- No --> G{is304 in errorMsg?}
    G -- Yes --> C
    G -- No --> H[warnETagGuardFailure]
    H --> I{isTransientNetworkError?}
    I -- No --> J[observer.log warn always]
    I -- Yes --> K{warningKey in\ntransientNetworkWarningKeys?}
    K -- Yes, suppress --> L[return true\nassume changed]
    K -- No --> M[add key to Set\npruneIfNeeded]
    M --> J
    J --> L
Loading

Reviews (3): Last reviewed commit: "fix(scm-github): clear etag warnings on ..." | Re-trigger Greptile

Comment thread packages/plugins/scm-github/src/graphql-batch.ts
@ChiragArora31 ChiragArora31 changed the title Throttle repeated GitHub ETag network warnings fix(scm-github): throttle repeated GitHub ETag network warnings Apr 29, 2026
@ChiragArora31

Copy link
Copy Markdown
Contributor Author

Addressed all review points in 703e6b04.

  • Fixed the critical bug: both Guard 1 and Guard 2 now call markETagGuardSuccess(...) in catch-path 304 branches.
  • Updated Guard 3 to use shared warning throttling + success reset behavior (including catch-path 304).
  • Extracted and expanded transient network patterns (added ssl, tls, certificate, dial tcp).
  • Added bounded pruning for transient warning keys to prevent unbounded growth.
  • Extended tests for catch-304 recovery (Guards 1/2/3), Guard 3 throttling, and non-transient warnings not being suppressed.

Validation:

  • pnpm --filter @aoagents/ao-plugin-scm-github test -- test/graphql-batch.test.ts
  • pnpm --filter @aoagents/ao-plugin-scm-github typecheck

Clear suppression keys on catch-path 304 recovery for all guards, migrate Guard 3 to shared throttling, and expand transient network detection/tests so repeated warnings are deduped only for transient failures.

Made-with: Cursor
@ChiragArora31 ChiragArora31 force-pushed the fix/1526-etag-network-warning-throttle branch from 703e6b0 to a39c5c6 Compare May 5, 2026 12:47
Comment thread packages/plugins/scm-github/test/graphql-batch.test.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

…-1554

# Conflicts:
#	packages/plugins/scm-github/src/graphql-batch.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ETag Guard spams warnings on transient network failures

1 participant