fix(gamma): omit legacy non-binary market listings#99
Open
cesarenaldi wants to merge 2 commits into
Open
Conversation
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.
Summary
list_marketsomits markets that cannot be represented by the binaryMarketmodel while preserving keyset cursors.get_marketcontinues to fail with typedUnexpectedResponseErrorfor legacy multi-outcome markets.UserInputError.Verification
uv run pytest tests/unit/test_gamma_paginated_specs.py tests/unit/test_gamma_models.pyuv run pytest tests/integration/test_gamma_paginated.py::test_list_closed_markets_omits_legacy_multi_outcome_markets tests/integration/test_markets.py::test_get_market_rejects_legacy_multi_outcome_market_with_typed_erroruv run ruff check src/polymarket/_internal/actions/gamma.py src/polymarket/clients/public.py src/polymarket/clients/async_public.py src/polymarket/clients/secure.py src/polymarket/clients/async_secure.py tests/unit/test_gamma_paginated_specs.py tests/integration/test_gamma_paginated.py tests/integration/test_markets.pyuv run ruff format --check src/polymarket/_internal/actions/gamma.py src/polymarket/clients/public.py src/polymarket/clients/async_public.py src/polymarket/clients/secure.py src/polymarket/clients/async_secure.py tests/unit/test_gamma_paginated_specs.py tests/integration/test_gamma_paginated.py tests/integration/test_markets.pyuv run pyrightUnexpectedResponseErrorNote
Medium Risk
Changes public listing semantics and secure split/merge/redeem lookup errors when only legacy multi-outcome markets match; behavior is intentional but can surprise callers relying on full API rows or ambiguous error messages.
Overview
Aligns gamma market listing with the binary
Marketmodel by silently dropping legacy multi-outcome rows instead of failing pagination.list_markets/ keyset parsing:_make_keyset_parsernow accepts item parsers that returnNone; those entries are skipped whilenext_cursoris unchanged.list_markets_specuses new_parse_list_market, which keeps markets with exactly two string outcomes and skips others; malformedoutcomesstill raiseUnexpectedResponseError.Direct fetch:
get_marketbehavior is unchanged (still parses viaMarket.parse_response); public and secure client docstrings now state that non-binary markets raiseUnexpectedResponseError, andlist_marketsdocstrings note omissions.Trading helpers: When split/merge/redeem resolve a market via
list_marketsand the only match is filtered out,UserInputError("No market found for …") is raised before the old “expected exactly one” check.Tests cover parser filtering, integration for closed listings and legacy slug fetch, and updated relayer split-position expectations.
Reviewed by Cursor Bugbot for commit d4841ed. Bugbot is set up for automated code reviews on this repo. Configure here.