Skip to content

Commit ae73b9d

Browse files
authored
community[patch]: Fix NotionDBLoader 400 Error by conditionally adding filter parameter (langchain-ai#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 [langchain-ai#18009](langchain-ai#18009) - **Dependencies:** None - **Twitter handle:** @gunnzolder Co-authored-by: Anton Parkhomenko <anton@merge.rocks>
1 parent 2999d06 commit ae73b9d

File tree

1 file changed

+4
-1
lines changed
  • libs/community/langchain_community/document_loaders

1 file changed

+4
-1
lines changed

libs/community/langchain_community/document_loaders/notiondb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,14 @@ def _request(
207207
*,
208208
filter_object: Optional[Dict[str, Any]] = None,
209209
) -> Any:
210+
json_payload = query_dict.copy()
211+
if filter_object:
212+
json_payload["filter"] = filter_object
210213
res = requests.request(
211214
method,
212215
url,
213216
headers=self.headers,
214-
json={**query_dict, "filter": filter_object or {}},
217+
json=json_payload,
215218
timeout=self.request_timeout_sec,
216219
)
217220
res.raise_for_status()

0 commit comments

Comments
 (0)