You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by he...@apache.org on 2023/05/30 23:37:15 UTC
[incubator-devlake] branch release-v0.17 updated: cherry-pick(v0.17.0-beta9): #5083 (#5319)
This is an automated email from the ASF dual-hosted git repository.
hez pushed a commit to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.17 by this push:
new aaaac4658 cherry-pick(v0.17.0-beta9): #5083 (#5319)
aaaac4658 is described below
commit aaaac465869ff9360b7347d307360ee0f0ed3e8e
Author: Camille Teruel <ca...@gmail.com>
AuthorDate: Wed May 31 01:37:11 2023 +0200
cherry-pick(v0.17.0-beta9): #5083 (#5319)
* fix: Do not raise APIException when status < 400
* fix: Let jobs endpoint handle 204 NO CONTENT status
---------
Co-authored-by: Camille Teruel <ca...@meri.co>
---
backend/python/README.md | 4 ++--
backend/python/plugins/azuredevops/azuredevops/api.py | 2 +-
backend/python/plugins/azuredevops/azuredevops/streams/jobs.py | 6 ++++++
backend/python/pydevlake/pydevlake/api.py | 2 +-
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/backend/python/README.md b/backend/python/README.md
index a68cca8ea..192798e58 100644
--- a/backend/python/README.md
+++ b/backend/python/README.md
@@ -196,9 +196,9 @@ class MyPlugin(dl.Plugin):
def test_connection(self, connection: MyPluginConnection):
api = ...
response = ...
- if response.status_code != 401:
+ if response.status != 401:
raise Exception("Invalid credentials")
- if response.status_code != 200:
+ if response.status != 200:
raise Exception(f"Connection error {response}")
```
diff --git a/backend/python/plugins/azuredevops/azuredevops/api.py b/backend/python/plugins/azuredevops/azuredevops/api.py
index 3730b8877..4c63e507a 100644
--- a/backend/python/plugins/azuredevops/azuredevops/api.py
+++ b/backend/python/plugins/azuredevops/azuredevops/api.py
@@ -24,7 +24,7 @@ class AzurePaginator(Paginator):
return response.json['value']
def get_next_page_id(self, response) -> Optional[str]:
- return response.headers.get('x-ms-continuation')
+ return response.headers.get('x-ms-continuationtoken')
def set_next_page_param(self, request, next_page_id):
request.query_args['continuationToken'] = next_page_id
diff --git a/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py b/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
index 3ef53cfdf..4d0b3a194 100644
--- a/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
+++ b/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
@@ -15,6 +15,8 @@
from typing import Iterable
+from http import HTTPStatus
+
from azuredevops.api import AzureDevOpsAPI
from azuredevops.models import Job, Build, GitRepository
from azuredevops.streams.builds import Builds
@@ -31,6 +33,10 @@ class Jobs(Substream):
repo: GitRepository = context.scope
api = AzureDevOpsAPI(context.connection)
response = api.jobs(repo.org_id, repo.project_id, parent.id)
+ # If a build has failed before any jobs have started, e.g. due to a
+ # bad YAML file, then the jobs endpoint will return a 204 NO CONTENT.
+ if response.status == HTTPStatus.NO_CONTENT:
+ return
for raw_job in response.json["records"]:
if raw_job["type"] == "Job":
raw_job["build_id"] = parent.domain_id()
diff --git a/backend/python/pydevlake/pydevlake/api.py b/backend/python/pydevlake/pydevlake/api.py
index 69deb5c18..89678c2df 100644
--- a/backend/python/pydevlake/pydevlake/api.py
+++ b/backend/python/pydevlake/pydevlake/api.py
@@ -326,7 +326,7 @@ class API(APIBase):
@response_hook
def handle_error(self, response):
- if response.status != HTTPStatus.OK:
+ if response.status >= 400:
raise APIException(response)
@response_hook