Skip to content

Commit dfe0b74

Browse files
author
Anton Karpets
authored
🐛Source Gitlab: set error code 500 as retriable (#37505)
1 parent 88c9030 commit dfe0b74

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

airbyte-integrations/connectors/source-gitlab/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data:
1010
connectorSubtype: api
1111
connectorType: source
1212
definitionId: 5e6175e5-68e1-4c17-bff9-56103bbb0d80
13-
dockerImageTag: 4.0.0
13+
dockerImageTag: 4.0.1
1414
dockerRepository: airbyte/source-gitlab
1515
documentationUrl: https://docs.airbyte.com/integrations/sources/gitlab
1616
githubIssueLabel: source-gitlab

airbyte-integrations/connectors/source-gitlab/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "4.0.0"
6+
version = "4.0.1"
77
name = "source-gitlab"
88
description = "Source implementation for GitLab."
99
authors = [ "Airbyte <[email protected]>",]

airbyte-integrations/connectors/source-gitlab/source_gitlab/manifest.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ definitions:
4343
http_codes: [401]
4444
error_message: Unable to refresh the `access_token`, please re-authenticate in Sources > Settings.
4545
- type: HttpResponseFilter
46-
action: FAIL
46+
action: RETRY
4747
http_codes: [500]
48-
error_message: Unable to connect to Gitlab API with the provided credentials
4948
- type: HttpResponseFilter
5049
action: FAIL
5150
http_codes: [404]

airbyte-integrations/connectors/source-gitlab/unit_tests/test_source.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ def test_connection_invalid_projects_and_projects(config_with_project_groups, re
4343
)
4444

4545

46-
@pytest.mark.parametrize("error_code, expected_status", ((500, False), (401, False)))
47-
def test_connection_fail_due_to_api_error(error_code, expected_status, config, mocker, requests_mock):
46+
def test_connection_fail_due_to_api_error(config, mocker, requests_mock):
4847
mocker.patch("time.sleep")
48+
error_code = 401
4949
requests_mock.get("/api/v4/groups", status_code=error_code)
5050
source = SourceGitlab()
5151
status, msg = source.check_connection(logging.getLogger(), config)
5252
assert status is False
53-
assert msg.startswith(f"Unable to connect to stream projects")
53+
assert msg == (
54+
"Unable to connect to stream projects - Unable to refresh the `access_token`, "
55+
"please re-authenticate in Sources > Settings."
56+
)
5457

5558

5659
def test_connection_fail_due_to_api_error_oauth(oauth_config, mocker, requests_mock):
@@ -63,12 +66,13 @@ def test_connection_fail_due_to_api_error_oauth(oauth_config, mocker, requests_m
6366
"refresh_token": "new_refresh_token",
6467
}
6568
requests_mock.post("https://gitlab.com/oauth/token", status_code=200, json=test_response)
66-
requests_mock.get("/api/v4/groups", status_code=500)
69+
requests_mock.get("/api/v4/groups", status_code=401)
6770
source = SourceGitlab()
6871
status, msg = source.check_connection(logging.getLogger(), oauth_config)
6972
assert status is False
70-
assert msg.startswith(
71-
"Unable to connect to stream projects - Unable to connect to Gitlab API with the provided credentials"
73+
assert msg == (
74+
"Unable to connect to stream projects - Unable to refresh the `access_token`, "
75+
"please re-authenticate in Sources > Settings."
7276
)
7377

7478

docs/integrations/sources/gitlab.md

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Gitlab has the [rate limits](https://docs.gitlab.com/ee/user/gitlab_com/index.ht
109109

110110
| Version | Date | Pull Request | Subject |
111111
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
112+
| 4.0.1 | 2024-04-23 | [37505](https://github.com/airbytehq/airbyte/pull/37505) | Set error code `500` as retriable |
112113
| 4.0.0 | 2024-03-25 | [35989](https://github.com/airbytehq/airbyte/pull/35989) | Migrate to low-code |
113114
| 3.0.0 | 2024-01-25 | [34548](https://github.com/airbytehq/airbyte/pull/34548) | Fix merge_request_commits stream to return commits for each merge request |
114115
| 2.1.2 | 2024-02-12 | [35167](https://github.com/airbytehq/airbyte/pull/35167) | Manage dependencies with Poetry. |

0 commit comments

Comments
 (0)