Skip to content

Commit 69f6d11

Browse files
fix: ensure file data are only sent as 1 parameter
1 parent 9e86464 commit 69f6d11

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/beeper_desktop_api/_utils/_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def _extract_items(
8686
index += 1
8787
if is_dict(obj):
8888
try:
89-
# We are at the last entry in the path so we must remove the field
90-
if (len(path)) == index:
89+
# Remove the field if there are no more dict keys in the path,
90+
# only "<array>" traversal markers or end.
91+
if all(p == "<array>" for p in path[index:]):
9192
item = obj.pop(key)
9293
else:
9394
item = obj[key]

tests/test_extract_files.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ def test_multiple_files() -> None:
3535
assert query == {"documents": [{}, {}]}
3636

3737

38+
def test_top_level_file_array() -> None:
39+
query = {"files": [b"file one", b"file two"], "title": "hello"}
40+
assert extract_files(query, paths=[["files", "<array>"]]) == [
41+
("files[]", b"file one"),
42+
("files[]", b"file two"),
43+
]
44+
assert query == {"title": "hello"}
45+
46+
3847
@pytest.mark.parametrize(
3948
"query,paths,expected",
4049
[

0 commit comments

Comments
 (0)