Skip to content

fix(fund): reject an invalid filter JSON in the C and Java bindings - #635

Open
hogan-yuan wants to merge 2 commits into
mainfrom
fix/fund-filter-invalid-json
Open

hogan-yuan wants to merge 2 commits into
mainfrom
fix/fund-filter-invalid-json

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

FundContext.funds takes the server-defined filter as a JSON string. The C (lb_fund_context_funds) and Java bindings parsed it with if let Ok(..) and dropped it on a parse error, so the request went out unfiltered and the caller got the whole fund catalogue back as if the filter had applied — no error anywhere. Node.js and Python already reject it (invalid filter JSON: …).

What changes

  • C / C++: the parse error is returned through the callback as a JSON decode error.
  • Java: throws RuntimeException("invalid filter JSON: …"), the same way HttpClient.request reports an unparsable body.
  • Doc comments on lb_get_funds_options_t.filter and GetFundsOptions.setFilter say so; longbridge.h regenerated.

A null / unset filter is unchanged.

🤖 Generated with Claude Code

lb_fund_context_funds and the Java FundContext.funds binding parsed the filter with if-let Ok(..) and silently dropped it on a parse error, so the request went out unfiltered and returned the whole fund catalogue. Propagate the parse error instead (C: JSON decode error via the callback; Java: RuntimeException), matching Node.js and Python.
Match the message Java, Node.js and Python already use, document the behaviour on the C++ GetFundsOptions::filter and that Java throws synchronously from funds(), and unit-test build_get_funds_options with invalid, valid and absent filters.

This branch has not been deployed

No deployments
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