Skip to content

Commit

Permalink
🐛 Source Tempo: Avoid infinite loop for non-paginated APIs (airbytehq…
Browse files Browse the repository at this point in the history
…#16361)

* 🐛 Source Tempo: Avoid infinite loop for APIs that do not support pagination and support more than DEFAULT_ITEMS_PER_PAGE results.

* Source Tempo: Update changelog for version 0.2.6

* fix: update additionalProperties to true

* fix: remove additionalProperties field in schema files

Co-authored-by: Sajarin <sajarindider@gmail.com>
  • Loading branch information
2 people authored and robbinhan committed Sep 29, 2022
1 parent 77b32c4 commit ae8b2e5
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@
- name: Tempo
sourceDefinitionId: d1aa448b-7c54-498e-ad95-263cbebcd2db
dockerRepository: airbyte/source-tempo
dockerImageTag: 0.2.5
dockerImageTag: 0.2.6
documentationUrl: https://docs.airbyte.io/integrations/sources/tempo
icon: tempo.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10427,7 +10427,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-tempo:0.2.5"
- dockerImage: "airbyte/source-tempo:0.2.6"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/"
connectionSpecification:
Expand All @@ -10436,7 +10436,6 @@
type: "object"
required:
- "api_token"
additionalProperties: false
properties:
api_token:
type: "string"
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-tempo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_tempo ./source_tempo
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.5
LABEL io.airbyte.version=0.2.6
LABEL io.airbyte.name=airbyte/source-tempo
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class Client(BaseClient):

PARAMS = {"limit": DEFAULT_ITEMS_PER_PAGE, "offset": 0}
ENTITIES_MAP = {
"accounts": {"url": "/accounts", "func": lambda v: v["results"], "params": PARAMS},
"customers": {"url": "/customers", "func": lambda v: v["results"], "params": PARAMS},
"worklogs": {"url": "/worklogs", "func": lambda v: v["results"], "params": PARAMS},
"workload-schemes": {"url": "/workload-schemes", "func": lambda v: v["results"], "params": PARAMS},
"accounts": {"url": "/accounts", "func": lambda v: v["results"], "paginated": False, "params": PARAMS},
"customers": {"url": "/customers", "func": lambda v: v["results"], "paginated": False, "params": PARAMS},
"worklogs": {"url": "/worklogs", "func": lambda v: v["results"], "paginated": True, "params": PARAMS},
"workload-schemes": {"url": "/workload-schemes", "func": lambda v: v["results"], "paginated": True, "params": PARAMS},
}

def __init__(self, api_token):
Expand All @@ -38,7 +38,7 @@ def lists(self, name, url, params, func, **kwargs):
response = requests.get(f"{self.base_api_url}{url}?limit={params['limit']}&offset={params['offset']}", headers=self.headers)
data = func(response.json())
yield from data
if len(data) < self.DEFAULT_ITEMS_PER_PAGE:
if not self.ENTITIES_MAP[name]["paginated"] or len(data) < self.DEFAULT_ITEMS_PER_PAGE:
break
params["offset"] += self.DEFAULT_ITEMS_PER_PAGE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,5 @@
}
}
}
},
"additionalProperties": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
"name": {
"type": "string"
}
},
"additionalProperties": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@
}
}
}
},
"additionalProperties": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
"issue": {
"type": "object",
"description": "Details of the issue",
"additionalProperties": {
"type": ["string", "integer"],
"readOnly": true
},
"readOnly": true
},
"timeSpentSeconds": {
Expand Down Expand Up @@ -60,22 +56,16 @@
"author": {
"type": "object",
"description": "Author of the worklog",
"readOnly": true,
"additionalProperties": {
"type": "string",
"readOnly": true
}
"readOnly": true
},
"attributes": {
"type": "object",
"description": "Additional attribute of the worklog",
"readOnly": true,
"additionalProperties": true
"readOnly": true
},
"billableSeconds": {
"type": ["null", "integer"],
"description": "Billable time spent working"
}
},
"additionalProperties": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"title": "Tempo Spec",
"type": "object",
"required": ["api_token"],
"additionalProperties": false,
"properties": {
"api_token": {
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/tempo.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ Go to **Tempo &gt; Settings**, scroll down to **Data Access** and select **API i

| Version | Date | Pull Request | Subject |
| :------ | :-------- | :----- | :------ |
| 0.2.6 | 2022-09-08 | [16361](https://github.com/airbytehq/airbyte/pull/16361) | Avoid infinite loop for non-paginated APIs |
| 0.2.4 | 2021-11-08 | [7649](https://github.com/airbytehq/airbyte/pull/7649) | Migrate to the CDK |

0 comments on commit ae8b2e5

Please sign in to comment.