Skip to content

[8.19] [GitHub] Propagate fetch errors instead of swallowing them (#4119) - #4136

Merged
Jan-Kazlouski-elastic merged 2 commits into
8.19from
backport/8.19/pr-4119
Jul 8, 2026
Merged

Jan-Kazlouski-elastic merged 2 commits into
8.19from
backport/8.19/pr-4119

Conversation

@Jan-Kazlouski-elastic

Copy link
Copy Markdown
Contributor

Summary

Manual backport of #4119 to 8.19.

The GitHub connector previously wrapped each fetch method in try/except Exception: log warning, so a sync could "succeed" while syncing nothing (e.g. if no issues could be fetched at all). This ports the two-tier error handling, removes the broad exception handling, and hardens null-handling of GraphQL responses.

The automated backport could not cherry-pick because main has since split the GitHub connector into a package (app/connectors_service/connectors/sources/github/{client,datasource,utils}.py), whereas 8.19 still uses the single module connectors/sources/github.py. The changes were therefore ported by hand into that single module.

Changes

  • Two-tier error handling: page/API-level failures propagate out of _fetch_repos / _fetch_pull_requests / _fetch_issues / _fetch_files / _fetch_files_by_path (so the sync fails when data genuinely can't be fetched), while per-document enrichment failures are WARN-logged and skipped via narrow gidgethub.GitHubException guards.
  • Transient rate limiting: added RateLimitingError. _put_to_sleep now only sleeps; its callers (get_github_item, graphql, _update_installation_access_token, _github_app_get) re-raise RateLimitingError, which is not in skipped_exceptions, so the existing @retryable layer retries it.
  • No more bare except Exception: replaced with gidgethub.GitHubException (plus the connector's own UnauthorizedException / ForbiddenException in log-and-reraise spots like ping and _get_invalid_repos_for_personal_access_token).
  • Null-safe GraphQL handling: switched connection-field access (reviews, comments, labels, assignees, reviewRequests, tree, edge nodes) to the ... or {} / ... or [] idiom so a single document with null connection fields can no longer abort the sync.
  • Tests: ported coverage for propagation vs. per-item skip for each fetch method, RateLimitingError propagation, null-connection-field regressions, and the deepcopy test-isolation fixes.

Test plan

  • make clean install autoformat lint test PYTHON=python3.11 — lint clean; tests/sources/test_github.py passes (121 passed), overall coverage 92.35%.
  • The only failures in the full suite are pre-existing pytest-randomly ordering flakiness in test_google_drive.py / test_google_cloud_storage.py (they pass in isolation and with a deterministic order); they are unrelated to these GitHub-only changes.

Part of #2393, closes #2395 for 8.19.

Made with Cursor

)

Backport of #4119 to 8.19. The GitHub connector previously wrapped each
fetch method in `try/except Exception: log warning`, so a sync could
"succeed" while syncing nothing. This ports the two-tier error handling,
removes broad exception handling, and hardens null-handling of GraphQL
responses.

- Page/API-level failures now propagate out of _fetch_repos /
  _fetch_pull_requests / _fetch_issues / _fetch_files /
  _fetch_files_by_path, failing the sync when data can't be fetched.
- Per-document enrichment failures are WARN-logged and skipped via narrow
  gidgethub.GitHubException guards.
- Add RateLimitingError; _put_to_sleep now only sleeps and its callers
  re-raise RateLimitingError so the @retryable layer retries it.
- Replace bare `except Exception` with gidgethub.GitHubException (plus the
  connector's own Unauthorized/Forbidden exceptions in log-and-reraise
  spots like ping and _get_invalid_repos_for_personal_access_token).
- Switch connection-field access to the `... or {}` / `... or []` idiom so
  null GraphQL connection fields no longer abort the sync.

Ported to the single-module 8.19 layout (connectors/sources/github.py).

Co-authored-by: Cursor <cursoragent@cursor.com>
@Jan-Kazlouski-elastic
Jan-Kazlouski-elastic enabled auto-merge (squash) July 8, 2026 08:36
@Jan-Kazlouski-elastic
Jan-Kazlouski-elastic merged commit 22a99bc into 8.19 Jul 8, 2026
2 checks passed
@Jan-Kazlouski-elastic
Jan-Kazlouski-elastic deleted the backport/8.19/pr-4119 branch July 8, 2026 08:53
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.

2 participants