kite-cli
kite-cli copied to clipboard
`alerts modify --rhs` sends an empty `rhs_attribute` for a constant alert
Summary
kite alerts modify <uuid> --rhs EXCHANGE:SYMBOL on a constant alert sends an empty rhs_attribute instead of the documented default, LastTradedPrice.
Steps to reproduce
- Start with a constant alert, such as the
NIFTY 50 >= 27000alert inalerts_get_one.json. - Run
kite --json alerts modify <uuid> --rhs NSE:INFY. Without--confirm, this prints the request as a dry run. - Look at
body.form.rhs_attribute.
Expected
rhs_attribute is LastTradedPrice. The help for --rhs-attribute says "Defaults to LastTradedPrice for a new instrument condition" (src/cli.rs:409).
Actual
rhs_attribute is "". Adding --confirm sends the same empty value in the PUT form.
Cause
- Kite returns empty strings for the instrument fields of a constant alert (
alerts_get_one.jsonL14-L17). - The
kiteconnectcrate types this field asOption<String>(src/alerts.rs:283), so""arrives asSome(""). - The fallback is
--rhs-attribute→ the stored alert'srhs_attribute→"LastTradedPrice"(src/commands/alerts.rs:150-159). It stops atSome(""), so the default is never used.
Creating an alert isn't affected, and neither is modifying an alert that already compares against an instrument.
Found using the kiteconnect-mocks fixtures only. I haven't checked how the live Kite API handles an empty rhs_attribute.
Fix
https://github.com/zerodha/kite-cli/pull/1