Skip to content

fix(bfabric): reserve query elements for other fields in read_multi - #574

Merged
leoschwarz merged 2 commits into
mainfrom
fix/multi-query-element-budget
Aug 10, 2026
Merged

fix(bfabric): reserve query elements for other fields in read_multi#574
leoschwarz merged 2 commits into
mainfrom
fix/multi-query-element-budget

Conversation

@leoschwarz

Copy link
Copy Markdown
Member
  • MultiQuery.read_multi now shrinks its chunk size by the elements the other query fields use, so e.g. read_multi("importresource", {"containerid": cid}, "relativepath", paths) no longer fails with "Query has 101 elements and exceeds the maximum of 100 allowed elements".
  • A query whose other fields already use up the 100-element limit raises ValueError instead of being sent.

Fixes #379

🤖 Prepared with assistance from Claude Opus 5 via Claude Code.

The B-Fabric API counts every value of a query towards its limit of 100
elements, but MultiQuery.read_multi chunked the multi-query values at the
full limit, so any additional query field pushed the request over it:
read_multi("importresource", {"containerid": cid}, "relativepath", paths)
failed with "Query has 101 elements and exceeds the maximum of 100 allowed
elements" once 100 paths were passed.

The chunk size is now reduced by the number of elements the remaining query
fields use (nested containers counted by their leaves, so unknown shapes
over- rather than under-count), and a query that leaves no room at all
raises ValueError instead of being sent. Values inside multi_query_vals are
still counted as one element each.

page_iter gains a type parameter so the query dict is no longer inferred as
partially unknown; both basedpyright baselines shrink accordingly.

Fixes #379
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📝 "TODO" Changes Detected

Summary: ➕ 1 "TODO" added, ✅ 2 "TODO"s removed

➕ Added "TODO"s (1)

  • bfabric/src/bfabric/experimental/multi_query.py:68: # TODO the case of multiple responses per value is untested, and there is no max_results here, so a query

✅ Removed "TODO"s (2)

  • bfabric/src/bfabric/experimental/multi_query.py:51: # TODO: Test what happens if there are multiple responses to each of the individual queries.
  • bfabric/src/bfabric/experimental/multi_query.py:56: # TODO: It is assumed that a user requesting multi_query always wants all of the pages. Can anybody think of

This comment is automatically updated when "TODO" changes are detected.

@leoschwarz
leoschwarz marked this pull request as ready for review August 10, 2026 07:20
@leoschwarz
leoschwarz merged commit 510b7fe into main Aug 10, 2026
24 checks passed
@leoschwarz
leoschwarz deleted the fix/multi-query-element-budget branch August 10, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MultiQuery read is broken when passing additional query

1 participant