Repository navigation
Conversation
_order_to_pb, _sort_by_to_pb, _collection_sort_by_to_pb, _document_sort_by_to_pb and _hnsw_metric_to_pb matched the known literals and returned a default (or the UNKNOWN enum) for anything else, so order="dsc" listed ascending, sort_by="created" sorted by the default column, and metric_space="cos" created a collection with an unknown metric, all without a word. Every other literal parameter in the SDK raises ValueError with the accepted values (reasoning_effort, service_tier, search mode, image format/quality/resolution). Unknown non-None values now raise ValueError the same way; None keeps its meaning as the default. Tests for each helper; they fail on main.
deanrie
force-pushed
the
reject-unknown-sort-order
branch
from
October 24, 2026 09:54
7175292 to
a1b954d
Compare
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
The listing helpers in
files.pyandcollections.pyconvert theorder,sort_by, andmetric_spaceliterals to protobuf enums with amatchwhosecase _returns a default (or theUNKNOWNenum value):So at runtime
client.files.list(order="dsc")lists ascending,sort_by="created"sorts by the default column, andcollections.create(metric_space="cos")creates a collection withHNSW_METRIC_UNKNOWN, all without a word. Type checkers catch these for literal arguments, but values that come from config, CLI flags, or user input reach the SDK as plainstr.Every other literal parameter in the SDK already raises:
reasoning_effort(chat.py),service_tier, searchmode, imageformat/quality/aspect_ratio/resolution, field definitionop. This change brings the five sort/order/metric helpers in line: an unknown non-Nonevalue raisesValueErrornaming the accepted values;Nonekeeps its current meaning (the default, orORDERING_UNKNOWNfor collections, which lets the server choose).Tests
tests/sync/files_test.py:"dsc"and"created"raise with the expected messages; existingNoneassertions unchanged.tests/sync/collections_test.py:"dsc","names","created","cos"raise;Nonestill maps to the previous defaults.Both new tests fail on
main.uv run pyteston the four files/collections test modules: 251 passed.ruff check,ruff format --check,pyrightclean on the touched files.