Skip to content
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

🐛Source GitLab: Fix syncing branches for the project with Repository feature disabled #26422

Conversation

tolik0
Copy link
Contributor

@tolik0 tolik0 commented May 23, 2023

What

Fix syncing branches for the project with the Repository feature disabled
#23130

How

Added try..except for read_records of branches stream

Tests

Test for repository feature disabled

airbyte/airbyte-integrations/connectors/source-gitlab# python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog_branches.json
{"type": "LOG", "log": {"level": "INFO", "message": "Starting syncing SourceGitlab"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Marking stream branches as STARTED"}}
{"type": "TRACE", "trace": {"type": "STREAM_STATUS", "emitted_at": 1684844308347.508, "stream_status": {"stream_descriptor": {"name": "branches", "namespace": null}, "status": "STARTED"}}}
{"type": "LOG", "log": {"level": "INFO", "message": "Syncing stream: branches "}}
{"type": "LOG", "log": {"level": "ERROR", "message": "{"message":"404 Repository Not Found"}"}}
{"type": "LOG", "log": {"level": "WARN", "message": "Got 404 error when accessing branches. Very likely the feature is disabled for this project and/or group. Please double check it, or report a bug otherwise."}}
{"type": "LOG", "log": {"level": "INFO", "message": "Read 0 records from branches stream"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Marking stream branches as STOPPED"}}
{"type": "TRACE", "trace": {"type": "STREAM_STATUS", "emitted_at": 1684844314462.594, "stream_status": {"stream_descriptor": {"name": "branches", "namespace": null}, "status": "COMPLETE"}}}
{"type": "LOG", "log": {"level": "INFO", "message": "Finished syncing branches"}}
{"type": "LOG", "log": {"level": "INFO", "message": "SourceGitlab runtimes:\nSyncing stream branches 0:00:06.115927"}}
{"type": "LOG", "log": {"level": "INFO", "message": "Finished syncing SourceGitlab"}}

Integration

airbyte/airbyte# ./gradlew :airbyte-integrations:connectors:source-gitlab:integrationTest Starting a Gradle Daemon (subsequent builds will be faster) Building all of Airbyte. /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors

Task :airbyte-integrations:connectors:source-gitlab:checkPython
Using python 3.10.6 from /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv (.venv/bin/python)
Using pip 21.3.1 from /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv/lib/python3.10/site-packages/pip (python 3.10)

Task :airbyte-integrations:connectors:source-gitlab:pipInstall
[python] .venv/bin/python -m pip install pip==21.3.1
Requirement already satisfied: pip==21.3.1 in ./.venv/lib/python3.10/site-packages (21.3.1)
WARNING: You are using pip version 21.3.1; however, version 23.1.2 is available.
You should consider upgrading via the '/home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv/bin/python -m pip install --upgrade pip' command.
[python] .venv/bin/python -m pip list --format=columns
Package Version Editable project location
------------------------- -------- -----------------------------------------------------------------------------------
airbyte-cdk 0.37.0
airbyte-protocol-models 0.3.6
attrs 23.1.0
backoff 2.2.1
black 22.3.0
cachetools 5.3.0
cattrs 22.2.0
certifi 2023.5.7
charset-normalizer 3.1.0
click 8.1.3
connector-acceptance-test 0.0.0 /home/anatolii/airbyte/airbyte/airbyte-integrations/bases/connector-acceptance-test
coverage 6.3.1
deepdiff 5.8.1
Deprecated 1.2.13
docker 5.0.3
dpath 2.0.8
exceptiongroup 1.1.1
fancycompleter 0.9.1
flake8 4.0.1
genson 1.2.2
hypothesis 6.54.6
hypothesis-jsonschema 0.20.1
icdiff 1.9.1
idna 3.4
inflection 0.5.1
iniconfig 2.0.0
isodate 0.6.1
isort 5.6.4
Jinja2 3.1.2
jsonref 0.2
jsonschema 3.2.0
MarkupSafe 2.1.2
mccabe 0.6.1
multidict 6.0.4
mypy 0.930
mypy-extensions 1.0.0
ordered-set 4.1.0
packaging 23.1
pathspec 0.11.1
pdbpp 0.10.3
pendulum 2.1.2
pip 21.3.1
platformdirs 3.5.1
pluggy 1.0.0
pprintpp 0.4.0
py 1.11.0
pycodestyle 2.8.0
pydantic 1.9.2
pyflakes 2.4.0
Pygments 2.15.1
pyproject-flake8 0.0.1a2
pyrepl 0.9.0
pyrsistent 0.19.3
pytest 6.2.5
pytest-cov 3.0.0
pytest-mock 3.6.1
pytest-sugar 0.9.7
pytest-timeout 1.4.2
python-dateutil 2.8.2
pytzdata 2020.1
PyYAML 5.4.1
requests 2.28.2
requests-cache 1.0.1
requests-mock 1.9.3
setuptools 67.7.2
six 1.16.0
sortedcontainers 2.4.0
source-gitlab 0.0.0
termcolor 2.3.0
toml 0.10.2
tomli 2.0.1
typing_extensions 4.6.0
url-normalize 1.4.3
urllib3 1.26.16
vcrpy 4.1.1
websocket-client 1.5.2
wheel 0.40.0
wmctrl 0.4
wrapt 1.15.0
yarl 1.9.2
WARNING: You are using pip version 21.3.1; however, version 23.1.2 is available.
You should consider upgrading via the '/home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv/bin/python -m pip install --upgrade pip' command.

Task :airbyte-integrations:connectors:source-gitlab:isortFormat
[python] .venv/bin/python -m isort --settings-file=/home/anatolii/airbyte/airbyte/pyproject.toml ./
Skipped 2 files

Task :airbyte-integrations:connectors:source-gitlab:blackFormat
[python] .venv/bin/python -m black --config /home/anatolii/airbyte/airbyte/pyproject.toml ./
All done! ✨ 🍰 ✨
5 files left unchanged.

Task :airbyte-integrations:connectors:source-gitlab:flakeCheck
[python] .venv/bin/python -m pflake8 --config /home/anatolii/airbyte/airbyte/pyproject.toml ./

Task :airbyte-integrations:connectors:source-gitlab:_unitTestCoverage
[python] .venv/bin/python -m coverage run --data-file=unit_tests/.coverage.unitTest --rcfile=/home/anatolii/airbyte/airbyte/pyproject.toml -m pytest -s unit_tests -c /home/anatolii/airbyte/airbyte/pyproject.toml
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.hypothesis/examples')
rootdir: /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/unit_tests, configfile: ../../../../pyproject.toml
plugins: sugar-0.9.7, cov-3.0.0, requests-mock-1.9.3, hypothesis-6.54.6, timeout-1.4.2, mock-3.6.1
collecting ... {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
{"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
{"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
{"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
{"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
collected 21 items

     unit_tests/test_source.py::test_streams[gitlab.com] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None groups.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
     PASSED
     unit_tests/test_source.py::test_streams[https:/gitlab.com] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None groups.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
     PASSED
     unit_tests/test_source.py::test_streams[https:/gitlab.com/api/v4] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None groups.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
     PASSED
     unit_tests/test_source.py::test_connection_success[gitlab.com] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None groups.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1, send_request=True)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups/g1?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Pre-write cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1, send_request=True)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p1?per_page=50&statistics=1 200", "data": {}}
     {"type": "DEBUG", "message": "Pre-write cache checks: Passed", "data": {}}
     PASSED
     unit_tests/test_source.py::test_connection_success[https:/gitlab.com] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None groups.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     PASSED
     unit_tests/test_source.py::test_connection_success[https:/gitlab.com/api/v4] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 200", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None groups.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/groups.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Initializing backend: None projects.sqlite", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:responses", "data": {}}
     {"type": "DEBUG", "message": "Initialized SQLiteDict with serializer: None", "data": {}}
     {"type": "DEBUG", "message": "Opening connection to /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/projects.sqlite:redirects", "data": {}}
     {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     PASSED
     unit_tests/test_source.py::test_connection_fail[gitlab.com] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 5.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 1 tries. Waiting 5 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 10.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 2 tries. Waiting 10 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 20.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 3 tries. Waiting 20 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 40.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 4 tries. Waiting 40 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 80.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 5 tries. Waiting 80 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "ERROR", "message": "Giving up _send(...) after 6 tries (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     PASSED
     unit_tests/test_source.py::test_connection_fail[https:/gitlab.com] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 5.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 1 tries. Waiting 5 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 10.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 2 tries. Waiting 10 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 20.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 3 tries. Waiting 20 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 40.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 4 tries. Waiting 40 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 80.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 5 tries. Waiting 80 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "ERROR", "message": "Giving up _send(...) after 6 tries (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     PASSED
     unit_tests/test_source.py::test_connection_fail[https:/gitlab.com/api/v4] {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 5.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 1 tries. Waiting 5 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 10.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 2 tries. Waiting 10 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 20.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 3 tries. Waiting 20 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 40.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 4 tries. Waiting 40 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Backing off _send(...) for 80.0s (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     {"type": "LOG", "log": {"level": "INFO", "message": "Caught retryable error 'Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: ' after 5 tries. Waiting 80 seconds then retrying..."}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/groups?per_page=50 500", "data": {}}
     {"type": "LOG", "log": {"level": "ERROR", "message": "Giving up _send(...) after 6 tries (airbyte_cdk.sources.streams.http.exceptions.DefaultBackoffException: Request URL: https://gitlab.com/api/v4/groups?per_page=50, Response Code: 500, Response Text: )"}}
     PASSED
     unit_tests/test_streams.py::test_should_retry {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1, send_request=True)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1?per_page=50&statistics=1 403", "data": {}}
     {"type": "DEBUG", "message": "Pre-write cache checks: disabled status", "data": {}}
     {"type": "DEBUG", "message": "Skipping cache write for URL: https://gitlab.com/api/v4/projects/p_1?per_page=50&statistics=1", "data": {}}
     {"type": "LOG", "log": {"level": "WARN", "message": "Got 403 error when accessing URL https://gitlab.com/api/v4/projects/p_1?per_page=50&statistics=1. Very likely the feature is disabled for this project and/or group. Please double check it, or report a bug otherwise."}}
     PASSED
     unit_tests/test_streams.py::test_transform[stream0-response_mocks0-expected_records0] {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1, send_request=True)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1?per_page=50&statistics=1 200", "data": {}}
     {"type": "DEBUG", "message": "Pre-write cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/pipelines?per_page=50&updated_after=2023-05-09T14%3A58%3A26.584730%2B00%3A00&updated_before=2023-05-23+14%3A58%3A26.988132%2B00%3A00 200", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/pipelines/build_project_p1/jobs?per_page=50 200", "data": {}}
     PASSED
     unit_tests/test_streams.py::test_transform[stream1-response_mocks1-expected_records1] {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/repository/tags?per_page=50 200", "data": {}}
     PASSED
     unit_tests/test_streams.py::test_transform[stream2-response_mocks2-expected_records2] {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/releases?per_page=50 200", "data": {}}
     PASSED
     unit_tests/test_streams.py::test_transform[stream3-response_mocks3-expected_records3] {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/merge_requests?per_page=50&scope=all&updated_after=2023-05-09T14%3A58%3A26.584730%2B00%3A00&updated_before=2023-05-23+14%3A58%3A27.010882%2B00%3A00 200", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/merge_requests/mr_1?per_page=50 200", "data": {}}
     PASSED
     unit_tests/test_streams.py::test_updated_state[stream0-current_state0-latest_record0-new_state0] PASSED
     unit_tests/test_streams.py::test_updated_state[stream1-current_state1-latest_record1-new_state1] PASSED
     unit_tests/test_streams.py::test_updated_state[stream2-current_state2-latest_record2-new_state2] PASSED
     unit_tests/test_streams.py::test_updated_state[stream3-current_state3-latest_record3-new_state3] PASSED
     unit_tests/test_streams.py::test_updated_state[stream4-current_state4-latest_record4-new_state4] PASSED
     unit_tests/test_streams.py::test_updated_state[stream5-current_state5-latest_record5-new_state5] PASSED
     unit_tests/test_streams.py::test_blocked_branches {"type": "DEBUG", "message": "Cache directives from request headers: CacheDirectives()", "data": {}}
     {"type": "DEBUG", "message": "Pre-read cache checks: Passed", "data": {}}
     {"type": "DEBUG", "message": "Post-read cache actions: CacheActions(expire_after=-1)", "data": {}}
     {"type": "DEBUG", "message": "GET https://gitlab.com/api/v4/projects/p_1/branches?per_page=50 404", "data": {}}
     {"type": "LOG", "log": {"level": "ERROR", "message": ""}}
     {"type": "LOG", "log": {"level": "WARN", "message": "Got 404 error when accessing branches. Very likely the feature is disabled for this project and/or group. Please double check it, or report a bug otherwise."}}
     PASSED
     
     =============================== warnings summary ===============================
     unit_tests/test_streams.py:11
       /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/unit_tests/test_streams.py:11: DeprecationWarning: Call to deprecated class NoAuth. (Set `authenticator=None` instead) -- Deprecated since version 0.1.20.
         auth_params = {"authenticator": NoAuth(), "api_url": "gitlab.com"}
     
     .venv/lib/python3.10/site-packages/deprecated/classic.py:173: 10 warnings
     test_source.py: 81 warnings
       /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv/lib/python3.10/site-packages/deprecated/classic.py:173: DeprecationWarning: Call to deprecated class HttpAuthenticator. (Use requests.auth.AuthBase instead) -- Deprecated since version 0.1.20.
         return old_new1(cls, *args, **kwargs)
     
     .venv/lib/python3.10/site-packages/airbyte_cdk/sources/streams/http/http.py:45: 9 warnings
     test_source.py: 81 warnings
       /home/anatolii/airbyte/airbyte/airbyte-integrations/connectors/source-gitlab/.venv/lib/python3.10/site-packages/airbyte_cdk/sources/streams/http/http.py:45: DeprecationWarning: Call to deprecated class NoAuth. (Set `authenticator=None` instead) -- Deprecated since version 0.1.20.
         self._authenticator: HttpAuthenticator = NoAuth()
     
     -- Docs: https://docs.pytest.org/en/stable/warnings.html
     ======================= 21 passed, 182 warnings in 0.89s =======================

Task :airbyte-integrations:connectors:source-gitlab:unitTest
Name Stmts Miss Cover


source_gitlab/init.py 2 0 100%
source_gitlab/source.py 61 3 95%
source_gitlab/streams.py 288 16 94%

TOTAL 351 19 95%

Task :airbyte-integrations:connectors:source-gitlab:airbyteDocker
cat: .env: No such file or directory
#1 [internal] load .dockerignore
#1 transferring context: 97B 0.0s done
#1 DONE 0.1s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 513B 0.0s done
#2 DONE 0.1s

#3 [internal] load metadata for docker.io/library/python:3.9-slim
#3 DONE 2.4s

#4 [internal] load build context
#4 transferring context: 1.83kB 0.0s done
#4 DONE 0.0s

#5 [1/7] FROM docker.io/library/python:3.9-slim@sha256:4b1d0686095059e04d5c0fc3c6a67813b1d9f1428e8ae1d257b95e6b185ed144
#5 resolve docker.io/library/python:3.9-slim@sha256:4b1d0686095059e04d5c0fc3c6a67813b1d9f1428e8ae1d257b95e6b185ed144
#5 resolve docker.io/library/python:3.9-slim@sha256:4b1d0686095059e04d5c0fc3c6a67813b1d9f1428e8ae1d257b95e6b185ed144 0.1s done
#5 DONE 0.1s

#6 [2/7] RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*
#6 CACHED

#7 [3/7] WORKDIR /airbyte/integration_code
#7 CACHED

#8 [4/7] COPY setup.py ./
#8 CACHED

#9 [5/7] RUN pip install .
#9 CACHED

#10 [6/7] COPY source_gitlab ./source_gitlab
#10 CACHED

#11 [7/7] COPY main.py ./
#11 CACHED

#12 exporting to image
#12 exporting layers done
#12 writing image sha256:7eb40972eec3ea7e66e43b30d90c70dc7afb18ceddf12cdae4e09adbace0d52a done
#12 naming to docker.io/airbyte/source-gitlab:dev done
#12 DONE 0.0s

Task :airbyte-integrations:connectors:source-gitlab:connectorAcceptanceTest
latest: Pulling from airbyte/connector-acceptance-test
Digest: sha256:0a0ca20728b335df4470bbc55e20c7bc266e2199474d0af263022a62fb818907
Status: Image is up to date for airbyte/connector-acceptance-test:latest
docker.io/airbyte/connector-acceptance-test:latest
============================= test session starts ==============================
platform linux -- Python 3.9.11, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /test_input
plugins: cov-3.0.0, sugar-0.9.6, requests-mock-1.9.3, hypothesis-6.54.6, timeout-1.4.2, mock-3.6.1
collected 45 items

test_core.py .....................s............s...... [ 91%]
test_full_refresh.py . [ 93%]
test_incremental.py ... [100%]

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:100: The previous and actual specifications are identical.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:578: The previous and actual discovered catalogs are identical.
================== 43 passed, 2 skipped in 1133.91s (0:18:53) ==================

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 19m 53s
27 actionable tasks: 9 executed, 18 up-to-date

@CLAassistant
Copy link

CLAassistant commented May 23, 2023

CLA assistant check
All committers have signed the CLA.

@octavia-squidington-iii octavia-squidington-iii added the area/connectors Connector related issues label May 23, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 23, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan and you've followed all steps in the Breaking Changes Checklist
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • You, or an Airbyter, have run /test successfully on this PR - or on a non-forked branch
  • You've updated the connector's metadata.yaml file (new!)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label May 23, 2023
yield from super().read_records(sync_mode, cursor_field, stream_slice, stream_state)
except requests.exceptions.HTTPError as error:
status = error.response.status_code
if status == 404:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already do have handling of 403 error, could it be extended to also cope with 404?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because this fix is done only for branches stream.

Copy link
Collaborator

@davydov-d davydov-d May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make it customizable per stream, for instance:

class GitlabStream:
    non_retriable_codes: List[int] = [403]
    ...
    ...
    if response.status_code in self.non_retriable_codes:
        setattr(self, "raise_on_http_errors", False)
        self.logger.warning(
            f"Got 403 error when accessing URL {response.request.url}."
            f" Very likely the feature is disabled for this project and/or group. Please double check it, or report a bug otherwise.")
        return False
    return super().should_retry(response)
class Branches:
    non_retriable_codes = [403, 404]

@@ -86,7 +87,7 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str,
return {"page": self.page}

def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
if response.status_code == 403:
if response.status_code in [403, 404]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if response.status_code in [403, 404]:
if response.status_code != 200:

@tolik0
Copy link
Contributor Author

tolik0 commented May 24, 2023

/test connector=connectors/source-gitlab

🕑 connectors/source-gitlab https://github.com/airbytehq/airbyte/actions/runs/5069023243
✅ connectors/source-gitlab https://github.com/airbytehq/airbyte/actions/runs/5069023243
Python tests coverage:

Name                        Stmts   Miss  Cover
-----------------------------------------------
source_gitlab/__init__.py       2      0   100%
source_gitlab/source.py        61      3    95%
source_gitlab/streams.py      281     15    95%
-----------------------------------------------
TOTAL                         344     18    95%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:100: The previous and actual specifications are identical.
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:578: The previous and actual discovered catalogs are identical.
================== 43 passed, 2 skipped in 598.81s (0:09:58) ===================

…en-syncing-branch-from-repository-feature-disabled
@lazebnyi lazebnyi removed the request for review from girarda May 25, 2023 15:54
@tolik0 tolik0 merged commit 44c23d1 into master May 25, 2023
23 of 24 checks passed
@tolik0 tolik0 deleted the 23130-source-gitlab-error-404-not-found-when-syncing-branch-from-repository-feature-disabled branch May 25, 2023 15:58
@tolik0 tolik0 self-assigned this Jun 2, 2023
marcosmarxm pushed a commit to natalia-miinto/airbyte that referenced this pull request Jun 8, 2023
…feature disabled (airbytehq#26422)

Add handling blocked repository for branches stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/gitlab
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Gitlab - Error 404 Not Found when syncing branch from repository feature disabled
5 participants