Skip to content

fix(client): send bool query params instead of raising - #11

Merged
codemug merged 4 commits into
mainfrom
fix/bool-query-params
Jul 25, 2026
Merged

fix(client): send bool query params instead of raising#11
codemug merged 4 commits into
mainfrom
fix/bool-query-params

Conversation

@codemug

@codemug codemug commented Jul 25, 2026

Copy link
Copy Markdown
Owner

The bug

_make_request passed params to session.get untouched, and aiohttp/yarl reject bool and None query values outright:

Invalid variable type: value should be str, int or float, got False of type <class 'bool'>

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; None params 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:

screener(exchange="NASDAQ", is_etf=False, is_fund=False, is_actively_trading=True) → 3703
screener(exchange="NYSE",   is_etf=False, is_fund=False, is_actively_trading=True) → 2008

tests/test_base.py::TestQueryParamNormalization asserts the conversions and that no bool survives into the sent params. Full suite: 932 passed; the 3 failures in tests/test_catalog.py are pre-existing and unrelated (confirmed by re-running with this change stashed).

Also in this PR: trail-mcp deployment onto a discovered universe

  • Dockerfile installs the local aiofmp tree. 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.yaml swaps the fmp source's hand-listed 39 tickers for universe: {kind: financial_symbols} (~26k symbols). EDGAR deliberately stays on its short list — it backfills richer meta for the mega-caps.
  • Memory limit 1Gi → 3Gi. Measured, not guessed: a load peaks ~132Mi at 150 entities and grows ~0.04Mi/entity beyond that (loading is per-entity; the resulting panel stays tiny), so ~26k projects to ~1.2Gi.

Needs trail-fmp PR #3 for the universe option itself; without it the config key is inert.

🤖 Generated with Claude Code

codemug added 4 commits July 25, 2026 10:14
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.
@codemug
codemug merged commit aac43f1 into main Jul 25, 2026
1 check passed
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.

1 participant