Skip to content

fix(python): forward outcome_id to SOR buildOrder on explicit-ID path - #2115

Open
VaggelisGian wants to merge 2 commits into
pmxt-dev:mainfrom
VaggelisGian:fix/sor-outcome-id-forwarding
Open

fix(python): forward outcome_id to SOR buildOrder on explicit-ID path#2115
VaggelisGian wants to merge 2 commits into
pmxt-dev:mainfrom
VaggelisGian:fix/sor-outcome-id-forwarding

Conversation

@VaggelisGian

Copy link
Copy Markdown

Fixes #2025

What was broken

Python's hosted SOR escape path dropped the outcome identifier when create_order was called with explicit market_id/outcome_id. _execute_sor_order branches on kwargs.get("outcome") (client.py:3057): the MarketOutcome shorthand emits camelCase marketId/outcomeId, but the explicit-ID branch built only marketId/side/outcome/shares and never read kwargs["outcome_id"]. The None-filter then stripped the always-None "outcome" key, so the POST to /api/sor/buildOrder went out with no outcome identifier at all. TypeScript forwards the full caller input unchanged, so outcomeId always reaches the wire there.

What changed

One line: the explicit-ID branch now includes "outcomeId": kwargs.get("outcome_id"). The existing None-filter keeps every other call shape byte-identical. The dropped fee/denom/slippage_pct fields tracked in #1858 are deliberately out of scope, as is the hardcoded empty outcome_id on the returned Order (#1503).

Tests

New sdks/python/tests/test_sor_dispatch.py mocks the requests calls made by the SOR path (the path uses requests directly, unlike the httpx-based hosted flows) and asserts the captured buildOrder payload contains the caller-supplied outcomeId for both call shapes. The explicit-ID test fails before the fix (KeyError: 'outcomeId'); both pass after.

Verification

  • python -m pytest tests/ from sdks/python: 267 passed; only failures are the two pre-existing HOME-vs-USERPROFILE sandbox cases that fail identically on clean main.
  • bash scripts/verify-all.sh on this branch matches a clean checkout of main exactly: only the three known Windows-only sandbox defects fail, which pass on ubuntu-latest CI.
  • The edit sits outside client.py's BEGIN/END GENERATED METHODS region, so no generated artifacts change.

Python's hosted SOR escape path dropped the outcome identifier when
create_order was called with explicit market_id/outcome_id:
_execute_sor_order built the /api/sor/buildOrder params without ever
reading kwargs["outcome_id"], and its None-filter stripped the
always-None "outcome" key, so the request went out with no outcome
identifier at all. TypeScript forwards the full caller input
unchanged, so outcomeId always reaches the wire there.

Add outcomeId to the explicit-ID branch of _execute_sor_order. The
existing None-filter keeps every other call shape byte-identical.

Add a dispatch test that mocks the requests calls made by the SOR path
and asserts the captured buildOrder payload contains the
caller-supplied outcomeId for both the explicit-ID shape (fails before
the fix) and the MarketOutcome shorthand (control).

Fixes pmxt-dev#2025
Add a market_id-only dispatch case asserting outcomeId and outcome are
absent from the request when no outcome was supplied, so removal of the
None-filter in _execute_sor_order cannot regress the wire payload to an
explicit null.
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.

SDK drift: Python's SOR escape path drops the outcome identifier itself for the explicit market_id/outcome_id call path, not just economic params

1 participant