Skip to content

Commit

Permalink
Fix, no error if "Projects" feature is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr committed Mar 5, 2022
1 parent e34c357 commit 7d3378d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
- name: GitHub
sourceDefinitionId: ef69ef6e-aa7f-4af1-a01d-ef775033524e
dockerRepository: airbyte/source-github
dockerImageTag: 0.2.20
dockerImageTag: 0.2.21
documentationUrl: https://docs.airbyte.io/integrations/sources/github
icon: github.svg
sourceType: api
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.20
LABEL io.airbyte.version=0.2.21
LABEL io.airbyte.name=airbyte/source-github
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def read_records(self, stream_slice: Mapping[str, any] = None, **kwargs) -> Iter
# `Repositories` stream is not available for repositories not in an organization.
# Handle "404 Client Error: Not Found for url: https://api.github.com/orgs/<org_name>/repos?per_page=100" error.
error_msg = f"Syncing `Repositories` stream isn't available for organization `{stream_slice['organization']}`."
elif e.response.status_code == requests.codes.GONE and "/projects?" in error_msg:
elif e.response.status_code == requests.codes.GONE and error_msg == "Projects are disabled for this repository":
# Some repos don't have projects enabled and we we get "410 Client Error: Gone for
# url: https://api.github.com/repos/xyz/projects?per_page=100" error.
error_msg = f"Syncing `Projects` stream isn't available for repository `{stream_slice['repository']}`."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
from unittest.mock import MagicMock, patch

import pytest
import requests
import responses
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources.streams.http.exceptions import BaseBackoffException
from source_github.streams import PullRequestCommentReactions
from source_github.streams import Projects, PullRequestCommentReactions

DEFAULT_BACKOFF_DELAYS = [5, 10, 20, 40, 80]

Expand Down Expand Up @@ -47,3 +49,24 @@ def test_backoff_time(http_status, response_text, expected_backoff_time):
args = {"authenticator": None, "repositories": ["test_repo"], "start_date": "start_date", "page_size_for_large_streams": 30}
stream = PullRequestCommentReactions(**args)
assert stream.backoff_time(response_mock) == expected_backoff_time


@responses.activate
def test_projects_disabled():
kwargs = {"start_date": "start_date", "page_size_for_large_streams": 30, "repositories": ["test_repo"]}
stream = Projects(**kwargs)

responses.add(
"GET",
"https://api.github.com/repos/test_repo/projects",
status=requests.codes.GONE,
json={"message": "Projects are disabled for this repository", "documentation_url": "https://docs.github.com/v3/projects"},
)

slices = stream.stream_slices(sync_mode=SyncMode.full_refresh)
for slice in slices:
records = list(stream.read_records(stream_slice=slice, sync_mode=SyncMode.full_refresh))
assert records == []

assert len(responses.calls) == 1
assert responses.calls[0].request.url == "https://api.github.com/repos/test_repo/projects?per_page=100&state=all"
1 change: 1 addition & 0 deletions docs/integrations/sources/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Your token should have at least the `repo` scope. Depending on which streams you

| Version | Date | Pull Request | Subject |
|:--------|:-----------| :--- |:-------------------------------------------------------------------------------------------------------------|
| 0.2.21 | 2022-03-05 | [ ](https://github.com/airbytehq/airbyte/pull/ ) | Fix, no error if "Projects" feature is disabled |
| 0.2.20 | 2022-02-16 | [10384](https://github.com/airbytehq/airbyte/pull/10384) | Add new stream `Deployments`, `ProjectColumns`, `PullRequestCommits` |
| 0.2.19 | 2022-02-07 | [10211](https://github.com/airbytehq/airbyte/pull/10211) | Add human-readable error in case of incorrect organization or repo name |
| 0.2.18 | 2021-02-09 | [10193](https://github.com/airbytehq/airbyte/pull/10193) | Add handling secondary rate limits |
Expand Down

0 comments on commit 7d3378d

Please sign in to comment.