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 Recharge: skip stream if 403 received #17608

Merged
merged 5 commits into from
Oct 5, 2022
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 @@ -876,7 +876,7 @@
- name: Recharge
sourceDefinitionId: 45d2e135-2ede-49e1-939f-3e3ec357a65e
dockerRepository: airbyte/source-recharge
dockerImageTag: 0.2.2
dockerImageTag: 0.2.3
documentationUrl: https://docs.airbyte.io/integrations/sources/recharge
icon: recharge.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9168,7 +9168,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-recharge:0.2.2"
- dockerImage: "airbyte/source-recharge:0.2.3"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/recharge"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-recharge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.2
LABEL io.airbyte.version=0.2.3
LABEL io.airbyte.name=airbyte/source-recharge
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class RechargeStream(HttpStream, ABC):

limit = 250
page_num = 1
raise_on_http_errors = True

# regestring the default schema transformation
transformer: TypeTransformer = TypeTransformer(TransformConfig.DefaultSchemaNormalization)
Expand Down Expand Up @@ -61,13 +62,18 @@ def get_stream_data(self, response_data: Any) -> List[dict]:
return [response_data]

def should_retry(self, response: requests.Response) -> bool:
res = super().should_retry(response)
if res:
return res

# For some reason, successful responses contains incomplete data
content_length = int(response.headers.get("Content-Length", 0))
return response.status_code == 200 and content_length > len(response.content)
incomplete_data_response = response.status_code == 200 and content_length > len(response.content)
forbidden_error = isinstance(response.json(), dict) and response.status_code == requests.codes.FORBIDDEN

if incomplete_data_response:
return True
elif forbidden_error:
setattr(self, "raise_on_http_errors", False)
self.logger.error(f"Skiping stream {self.name} because of a 403 error.")
return False
arsenlosenko marked this conversation as resolved.
Show resolved Hide resolved

return super().should_retry(response)


class IncrementalRechargeStream(RechargeStream, ABC):
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/recharge.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The Recharge connector should gracefully handle Recharge API limitations under n

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.2.2 | 2022-10-05 | [17608](https://github.com/airbytehq/airbyte/pull/17608) | Skip stream if we receive 403 error
| 0.2.2 | 2022-09-28 | [17304](https://github.com/airbytehq/airbyte/pull/17304) | Migrate to per-stream state.
| 0.2.1 | 2022-09-23 | [17080](https://github.com/airbytehq/airbyte/pull/17080) | Fix `total_weight` value to be `int` instead of `float`
| 0.2.0 | 2022-09-21 | [16959](https://github.com/airbytehq/airbyte/pull/16959) | Use TypeTransformer to reliably convert to schema declared data types
Expand Down