Skip to content

🐛Source Gitlab: set error code 500 as retriable #37505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 5e6175e5-68e1-4c17-bff9-56103bbb0d80
dockerImageTag: 4.0.0
dockerImageTag: 4.0.1
dockerRepository: airbyte/source-gitlab
documentationUrl: https://docs.airbyte.com/integrations/sources/gitlab
githubIssueLabel: source-gitlab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "4.0.0"
version = "4.0.1"
name = "source-gitlab"
description = "Source implementation for GitLab."
authors = [ "Airbyte <[email protected]>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ definitions:
http_codes: [401]
error_message: Unable to refresh the `access_token`, please re-authenticate in Sources > Settings.
- type: HttpResponseFilter
action: FAIL
action: RETRY
http_codes: [500]
error_message: Unable to connect to Gitlab API with the provided credentials
- type: HttpResponseFilter
action: FAIL
http_codes: [404]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ def test_connection_invalid_projects_and_projects(config_with_project_groups, re
)


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


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


Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Gitlab has the [rate limits](https://docs.gitlab.com/ee/user/gitlab_com/index.ht

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 4.0.1 | 2024-04-23 | [37505](https://github.com/airbytehq/airbyte/pull/37505) | Set error code `500` as retriable |
| 4.0.0 | 2024-03-25 | [35989](https://github.com/airbytehq/airbyte/pull/35989) | Migrate to low-code |
| 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 |
| 2.1.2 | 2024-02-12 | [35167](https://github.com/airbytehq/airbyte/pull/35167) | Manage dependencies with Poetry. |
Expand Down
Loading