Skip to content

Commit 594230b

Browse files
girardasuhomud
authored andcommitted
Source Hubspot - Log instructions to update scopes when hitting 403 HTTP error (#12515)
* read workflows * try except * Revert "read workflows" This reverts commit 86db8ff. * Check campaigns * Check by reading data * Check all streams * requests_mock.ANY * mock all http methods * Try with get and post * reset to master * log name * bump version
1 parent e6170e0 commit 594230b

File tree

3 files changed

+42
-32
lines changed

3 files changed

+42
-32
lines changed

airbyte-integrations/connectors/source-hubspot/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ COPY source_hubspot ./source_hubspot
3434
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
3535
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
3636

37-
LABEL io.airbyte.version=0.1.55
37+
LABEL io.airbyte.version=0.1.56
3838
LABEL io.airbyte.name=airbyte/source-hubspot

airbyte-integrations/connectors/source-hubspot/source_hubspot/streams.py

+35-26
Original file line numberDiff line numberDiff line change
@@ -331,32 +331,41 @@ def read_records(
331331
pagination_complete = False
332332

333333
next_page_token = None
334-
with AirbyteSentry.start_transaction("read_records", self.name), AirbyteSentry.start_transaction_span("read_records"):
335-
while not pagination_complete:
336-
337-
properties_list = list(self.properties.keys())
338-
if properties_list:
339-
stream_records, response = self._read_stream_records(
340-
properties_list=properties_list,
341-
stream_slice=stream_slice,
342-
stream_state=stream_state,
343-
next_page_token=next_page_token,
344-
)
345-
records = [value for key, value in stream_records.items()]
346-
else:
347-
response = self.handle_request(stream_slice=stream_slice, stream_state=stream_state, next_page_token=next_page_token)
348-
records = self._transform(self.parse_response(response, stream_state=stream_state, stream_slice=stream_slice))
349-
350-
if self.filter_old_records:
351-
records = self._filter_old_records(records)
352-
yield from records
353-
354-
next_page_token = self.next_page_token(response)
355-
if not next_page_token:
356-
pagination_complete = True
357-
358-
# Always return an empty generator just in case no records were ever yielded
359-
yield from []
334+
try:
335+
with AirbyteSentry.start_transaction("read_records", self.name), AirbyteSentry.start_transaction_span("read_records"):
336+
while not pagination_complete:
337+
338+
properties_list = list(self.properties.keys())
339+
if properties_list:
340+
stream_records, response = self._read_stream_records(
341+
properties_list=properties_list,
342+
stream_slice=stream_slice,
343+
stream_state=stream_state,
344+
next_page_token=next_page_token,
345+
)
346+
records = [value for key, value in stream_records.items()]
347+
else:
348+
response = self.handle_request(
349+
stream_slice=stream_slice, stream_state=stream_state, next_page_token=next_page_token
350+
)
351+
records = self._transform(self.parse_response(response, stream_state=stream_state, stream_slice=stream_slice))
352+
353+
if self.filter_old_records:
354+
records = self._filter_old_records(records)
355+
yield from records
356+
357+
next_page_token = self.next_page_token(response)
358+
if not next_page_token:
359+
pagination_complete = True
360+
361+
# Always return an empty generator just in case no records were ever yielded
362+
yield from []
363+
except requests.exceptions.HTTPError as e:
364+
status_code = e.response.status_code
365+
if status_code == 403:
366+
raise RuntimeError(f"Invalid permissions for {self.name}. Please ensure the all scopes are authorized for.")
367+
else:
368+
raise e
360369

361370
@staticmethod
362371
def _convert_datetime_to_string(dt: pendulum.datetime, declared_format: str = None) -> str:

docs/integrations/sources/hubspot.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,13 @@ If you are using OAuth, most of the streams require the appropriate [scopes](htt
147147

148148
| Version | Date | Pull Request | Subject |
149149
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
150-
| 0.1.55 | 2022-04-28 | [12424](https://github.com/airbytehq/airbyte/pull/12424) | Correct schema for ticket_pipeline stream |
151-
| 0.1.54 | 2022-04-28 | [12335](https://github.com/airbytehq/airbyte/pull/12335) | Mock time slep in unit test s |
152-
| 0.1.53 | 2022-04-20 | [12230](https://github.com/airbytehq/airbyte/pull/12230) | chaneg spec json to yaml format |
150+
| 0.1.56 | 2022-05-02 | [12515](https://github.com/airbytehq/airbyte/pull/12515) | Extra logs for troubleshooting 403 errors |
151+
| 0.1.55 | 2022-04-28 | [12424](https://github.com/airbytehq/airbyte/pull/12424) | Correct schema for ticket_pipeline stream |
152+
| 0.1.54 | 2022-04-28 | [12335](https://github.com/airbytehq/airbyte/pull/12335) | Mock time slep in unit test s |
153+
| 0.1.53 | 2022-04-20 | [12230](https://github.com/airbytehq/airbyte/pull/12230) | chaneg spec json to yaml format |
153154
| 0.1.52 | 2022-03-25 | [11423](https://github.com/airbytehq/airbyte/pull/11423) | Add tickets associations to engagements streams |
154-
| 0.1.51 | 2022-03-24 | [11321](https://github.com/airbytehq/airbyte/pull/11321) | Fix updated at field non exists issue |
155-
| 0.1.50 | 2022-03-22 | [11266](https://github.com/airbytehq/airbyte/pull/11266) | Fix Engagements Stream Pagination |
155+
| 0.1.51 | 2022-03-24 | [11321](https://github.com/airbytehq/airbyte/pull/11321) | Fix updated at field non exists issue |
156+
| 0.1.50 | 2022-03-22 | [11266](https://github.com/airbytehq/airbyte/pull/11266) | Fix Engagements Stream Pagination |
156157
| 0.1.49 | 2022-03-17 | [11218](https://github.com/airbytehq/airbyte/pull/11218) | Anchor hyperlink in input configuration |
157158
| 0.1.48 | 2022-03-16 | [11105](https://github.com/airbytehq/airbyte/pull/11105) | Fix float numbers, upd docs |
158159
| 0.1.47 | 2022-03-15 | [11121](https://github.com/airbytehq/airbyte/pull/11121) | Add partition keys where appropriate |

0 commit comments

Comments
 (0)