Summary
The v1.x SDK returns MarketDataClientErrorResult from every endpoint method instead of raising exceptions. This violates SDK Requirements §6.4, which requires idiomatic Python error handling (raise exceptions). Tracking for v2.0 because every existing caller depends on the current return type.
The requirements doc names this explicitly:
*** Python SDK Technical Debt:** The current Python SDK (v1.x) returns MarketDataClientErrorResult instead of raising exceptions. This is non-idiomatic and will be fixed in v2.0.
Current behavior
handle_exceptions in src/marketdata/sdk_error.py wraps every endpoint method and converts any exception into a MarketDataClientErrorResult:
result = client.stocks.quotes("AAPL")
if isinstance(result, MarketDataClientErrorResult):
print(result.support_info)
v2 target
try:
quotes = client.stocks.quotes("AAPL")
except BaseMarketdataException as e:
print(e.support_info)
In-scope changes
- Remove the
handle_exceptions decorator (src/marketdata/sdk_error.py). Endpoint methods raise exceptions naturally.
- Remove
MarketDataClientErrorResult from the public API and from marketdata.__init__ re-exports.
- Move the
support_info formatted string from MarketDataClientErrorResult onto BaseMarketdataException so it's accessible via error.support_info (§6.3).
- Ensure every exception class carries the §6.2 support-context fields (
request_id, request_url, status_code, timestamp, message, exception_type). Currently only MarketdataHttpError subclasses have the HTTP fields; RateLimitError, MinMaxDateValidationError, KeywordOnlyArgumentError, InvalidStatusDataError extend BaseMarketdataException and lack them.
- Update every endpoint method in
src/marketdata/resources/**/*.py to drop MarketDataClientErrorResult from return type annotations and the from ... import MarketDataClientErrorResult lines.
- Update tests to use
pytest.raises instead of isinstance checks.
- Update README and docs with the new error-handling pattern.
Out of scope (separate v2 issues to follow)
- Expanding the exception taxonomy to add
AuthenticationError, BadRequestError, NotFoundError, ServerError, NetworkError, ParseError (§6.1).
- Status-code → exception mapping (§9.1: 401 fail-fast, 404 returns no-data response, etc.).
- Other v2 breaking changes (e.g. fixed/non-configurable timeout per §10).
Why this requires v2
Every caller currently does if isinstance(result, MarketDataClientErrorResult): .... Removing the type from the public API and changing return signatures to raise instead breaks all such callers — major version bump required.
Summary
The v1.x SDK returns
MarketDataClientErrorResultfrom every endpoint method instead of raising exceptions. This violates SDK Requirements §6.4, which requires idiomatic Python error handling (raise exceptions). Tracking for v2.0 because every existing caller depends on the current return type.The requirements doc names this explicitly:
Current behavior
handle_exceptionsinsrc/marketdata/sdk_error.pywraps every endpoint method and converts any exception into aMarketDataClientErrorResult:v2 target
In-scope changes
handle_exceptionsdecorator (src/marketdata/sdk_error.py). Endpoint methods raise exceptions naturally.MarketDataClientErrorResultfrom the public API and frommarketdata.__init__re-exports.support_infoformatted string fromMarketDataClientErrorResultontoBaseMarketdataExceptionso it's accessible viaerror.support_info(§6.3).request_id,request_url,status_code,timestamp,message,exception_type). Currently onlyMarketdataHttpErrorsubclasses have the HTTP fields;RateLimitError,MinMaxDateValidationError,KeywordOnlyArgumentError,InvalidStatusDataErrorextendBaseMarketdataExceptionand lack them.src/marketdata/resources/**/*.pyto dropMarketDataClientErrorResultfrom return type annotations and thefrom ... import MarketDataClientErrorResultlines.pytest.raisesinstead ofisinstancechecks.Out of scope (separate v2 issues to follow)
AuthenticationError,BadRequestError,NotFoundError,ServerError,NetworkError,ParseError(§6.1).Why this requires v2
Every caller currently does
if isinstance(result, MarketDataClientErrorResult): .... Removing the type from the public API and changing return signatures to raise instead breaks all such callers — major version bump required.