Skip to content

Commit

Permalink
🐛Source Notion: added handing empty results in response (#27073)
Browse files Browse the repository at this point in the history
* added handing empty results in response

* added changelog
  • Loading branch information
darynaishchenko committed Jun 7, 2023
1 parent 471568a commit 83b968a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-notion/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_notion ./source_notion
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=1.0.7
LABEL io.airbyte.version=1.0.8
LABEL io.airbyte.name=airbyte/source-notion
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 6e00b415-b02e-4160-bf02-58176a0ae687
dockerImageTag: 1.0.7
dockerImageTag: 1.0.8
dockerRepository: airbyte/source-notion
githubIssueLabel: source-notion
icon: notion.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def next_page_token(
return {"next_cursor": next_cursor}

def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
data = response.json().get("results")
# sometimes notion api returns response without results object
data = response.json().get("results", [])
yield from data


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ def test_should_not_retry_with_not_found_block(requests_mock):
assert not stream.should_retry(test_response)


def test_empty_blocks_results(requests_mock):
stream = Blocks(parent=None, config=MagicMock())
requests_mock.get(
"https://api.notion.com/v1/blocks/aaa/children",
json={
"next_cursor": None,
},
)
stream.block_id_stack = ["aaa"]
assert list(stream.read_records(sync_mode=SyncMode.incremental, stream_slice=[])) == []


def test_backoff_time(patch_base_class):
response_mock = MagicMock(headers={"retry-after": "10"})
stream = NotionStream(config=MagicMock())
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/notion.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The connector is restricted by Notion [request limits](https://developers.notion

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------|
| 1.0.8 | 2023-06-07 | [27073](https://github.com/airbytehq/airbyte/pull/27073) | Add empty results handling for stream `Blocks` |
| 1.0.7 | 2023-06-06 | [27060](https://github.com/airbytehq/airbyte/pull/27060) | Add skipping 404 error in `Blocks` stream |
| 1.0.6 | 2023-05-18 | [26286](https://github.com/airbytehq/airbyte/pull/26286) | Add `parent` field to `Blocks` stream |
| 1.0.5 | 2023-05-01 | [25709](https://github.com/airbytehq/airbyte/pull/25709) | Fixed `ai_block is unsupported by API` issue, while fetching `Blocks` stream |
Expand Down

0 comments on commit 83b968a

Please sign in to comment.