fix(client): send bool query params instead of raising - #11
Merged
Conversation
…es PVC + rolling periods
aiohttp/yarl reject bool and None query values outright ("Invalid variable
type: value should be str, int or float"), and params went to session.get
untouched. Any caller passing a boolean filter therefore raised before the
request left the process - screener(is_etf=False) could not be expressed at
all, which is most of the point of a screener.
Normalizing at the single choke point in _make_request fixes every endpoint
that takes boolean flags rather than patching them one at a time: bools become
the lowercase strings FMP expects, and None params are dropped so an unset
filter is simply not sent.
Verified against the live API: screener(exchange=..., is_etf=False,
is_fund=False, is_actively_trading=True) now returns the same counts that a
hand-built string-param request does (NASDAQ 3703, NYSE 2008).
Also rolls the trail-mcp deployment onto a discovered universe: the image
installs the local aiofmp tree (this fix is not released under a new version,
so pip would consider the PyPI wheel sufficient), the fmp source swaps its
hand-listed tickers for `universe: {kind: financial_symbols}`, and the memory
limit moves to 3Gi. That last number is measured, not guessed - a load peaks
~132Mi at 150 entities and grows ~0.04Mi/entity thereafter, so the ~26k-symbol
universe projects to ~1.2Gi.
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.
The bug
_make_requestpassedparamstosession.getuntouched, and aiohttp/yarl rejectboolandNonequery values outright:So any caller passing a boolean filter raised before the request left the process.
search.screener(is_etf=False, ...)— filtering out ETFs, which is most of the point of a screener — could not be expressed at all.The fix
Normalize once at the choke point rather than patching endpoints one at a time. Bools become the lowercase strings FMP expects;
Noneparams are dropped so an unset filter is simply not sent. Strings and ints pass through untouched.This repairs every boolean-flag endpoint, not just the screener.
Verification
Against the live API, the previously-impossible public call now matches the counts from a hand-built string-param request exactly:
tests/test_base.py::TestQueryParamNormalizationasserts the conversions and that noboolsurvives into the sent params. Full suite: 932 passed; the 3 failures intests/test_catalog.pyare pre-existing and unrelated (confirmed by re-running with this change stashed).Also in this PR: trail-mcp deployment onto a discovered universe
aiofmptree. This fix is not released under a new version, so pip would otherwise consider the same-versioned PyPI wheel sufficient and silently ship the broken client.trail.yamlswaps the fmp source's hand-listed 39 tickers foruniverse: {kind: financial_symbols}(~26k symbols). EDGAR deliberately stays on its short list — it backfills richer meta for the mega-caps.🤖 Generated with Claude Code