Skip to content

Commit

Permalink
community[patch]: Fix NotionDBLoader 400 Error by conditionally addin…
Browse files Browse the repository at this point in the history
…g filter parameter (#19075)

- **Description:** This change fixes a bug where attempts to load data
from Notion using the NotionDBLoader resulted in a 400 Bad Request
error. The issue was traced to the unconditional addition of an empty
'filter' object in the request payload, which Notion's API does not
accept. The modification ensures that the 'filter' object is only
included in the payload when it is explicitly provided and not empty,
thus preventing the 400 error from occurring.
- **Issue:** Fixes
[#18009](#18009)
- **Dependencies:** None
- **Twitter handle:** @gunnzolder

Co-authored-by: Anton Parkhomenko <anton@merge.rocks>
  • Loading branch information
gunnzolder and Anton Parkhomenko committed Mar 14, 2024
1 parent 2999d06 commit ae73b9d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,14 @@ def _request(
*,
filter_object: Optional[Dict[str, Any]] = None,
) -> Any:
json_payload = query_dict.copy()
if filter_object:
json_payload["filter"] = filter_object
res = requests.request(
method,
url,
headers=self.headers,
json={**query_dict, "filter": filter_object or {}},
json=json_payload,
timeout=self.request_timeout_sec,
)
res.raise_for_status()
Expand Down

0 comments on commit ae73b9d

Please sign in to comment.