fix(cli): correct market price labeling and status/comment filters#10
fix(cli): correct market price labeling and status/comment filters#10morluto wants to merge 4 commits intoPolymarket:mainfrom
Conversation
- Make market list price outcome-aware and rename column from Price (Yes) to Price\n- Restrict comments entity-type enum to Event/Series to match Gamma validation\n- Stop translating active into closed; apply active/closed filters independently in markets/events list\n- Add regression tests for outcome labeling and independent status filter behavior\n- Update README examples to match new market table output
|
Here is an explanation of the underlying issues this PR addresses. Problem OverviewThere were three separate but related correctness issues in the CLI:
Each issue produced behavior that could look valid at a glance but was semantically wrong. 1) Market list price labeling/mapping bugRoot causeThe table output was hardcoded as Why this is incorrectNot all markets are
User impactThis can mislead users reading table output, especially when quickly scanning markets to make decisions. The value could be numerically accurate for index 0 but semantically mislabeled. Fix approach
2) Comments entity type contract mismatchRoot causeCLI exposed User impactThe CLI accepted input that could never succeed server-side, resulting in avoidable runtime failures. Fix approach
3) Active/closed filter couplingRoot causeBoth
Why this is wrong
User impactUsers asking for one status dimension unintentionally received results filtered by another. This produced surprising/inaccurate query behavior. Fix approach
Verification Summary
|
- Keep markets list filling up to --limit when --active is set by paginating additional API pages\n- Preserve independent active/closed semantics while avoiding undersized result pages\n- Move shared Option<bool> filter matcher into commands/mod.rs and reuse in events/markets\n- Add/retain tests and run full suite
|
Follow-up:
Verification:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
- Preserve market list price display when outcomePrices is present but outcomes is absent\n- Fallback to unlabeled first outcome price instead of rendering an em dash\n- Add regression test for outcomes-missing case
Return empty result when limit <= 0 before pagination to avoid forcing one-row output.
|
Follow-up fixes: |
Summary
This PR fixes three CLI behavior issues in Gamma-facing commands/output:
markets listlabeled the price column as "Price (Yes)" and always used the first outcome price, which is incorrect for non-binary or differently ordered outcomes.comments list --entity-type marketwas exposed by the CLI even though Gamma comments only accept Event/Series.--activewas implicitly transformed into--closedinmarkets listandevents list(active=falsebecameclosed=true), causing misleading filter behavior.Problem Details
1) Market table outcome mismatch
The table output implied it always showed "Yes" while implementation used
outcome_prices.first(). For markets likeLong/Short,Dems/Reps, etc., the label and value mapping were wrong.2) Comments entity type mismatch with API contract
The CLI enum included
Marketand mapped toParentEntityType::Market, but Gamma returns422 invalid entity typefor that input.3) Status filter coupling
Both
marketsandeventslist commands derivedclosedfromactivewhenclosedwas omitted. This collapsed two independent filters into one derived filter and changed query intent.What Changed
Market output behavior
Price (Yes)toPrice.Yesoutcome price when present (case-insensitive match).<Outcome>: <price in cents>(e.g.Yes: 52.00¢,Long: 58.43¢,Dems: 41.00¢).Comments entity-type contract
Marketfrom CLIEntityTypeenum.EntityType::Market -> ParentEntityType::Marketmapping.event|seriesonly.Active/closed filter semantics
closed.or_else(|| active.map(|a| !a))translation.events listnow passesactiveandclosedindependently to the request builder.markets listandevents listnow apply independent status filtering in CLI logic via shared helper pattern:flag_matches(value, filter)apply_status_filters(items, active_filter, closed_filter)This preserves expected behavior even if API-side status fields are inconsistent.
Tests Added
src/output/markets.rsrow_prefers_yes_outcome_when_not_firstrow_uses_first_outcome_for_non_binary_marketrow_formats_price_as_centssrc/commands/comments.rsentity_type_does_not_expose_market_variantsrc/commands/markets.rsstatus_filters_are_independentactive_filter_does_not_imply_closed_filtersrc/commands/events.rsstatus_filters_are_independentactive_filter_does_not_imply_closed_filterDocumentation
Priceand outcome-prefixed values.Verification
Automated
cargo test101unit tests,49CLI integration tests)Manual / Runtime against live API
markets list --limit 50Priceheader and outcome-aware entries (Long: ...,Dems: ..., etc.)comments list --helpevent, seriescomments list --entity-type market ...markets/events --active falsevs--closed trueRisk / Compatibility
Price+ prefixed outcome label).comments list --entity-type marketis now rejected at parse-time.Changelog
active/closedsemantics in events/markets list filtersNote
Medium Risk
User-visible behavior changes in listing filters and table output, plus a breaking CLI flag value removal for comments; low security impact but could affect scripts relying on prior semantics/output.
Overview
Fixes several Gamma-facing CLI inconsistencies around listing filters and output.
markets listtable output now labels the column asPriceand renders an outcome-aware primary price (prefers theYesoutcome when present, otherwise the first outcome), including the outcome name in the cell (e.g.Yes: 52.00¢); README examples and unit tests were updated accordingly.comments listno longer exposes--entity-type market(event/series only), andevents list/markets liststop derivingclosedfromactive; instead,activeandclosedare treated as independent filters via a new sharedflag_matcheshelper with added tests.Written by Cursor Bugbot for commit 3c9cb35. This will update automatically on new commits. Configure here.