Skip to content

fix(alert): merge enable/disable into update across all language SDKs#524

Open
hogan-yuan wants to merge 2 commits into
mainfrom
fix/alert-enable-disable-missing-fields-v2
Open

fix(alert): merge enable/disable into update across all language SDKs#524
hogan-yuan wants to merge 2 commits into
mainfrom
fix/alert-enable-disable-missing-fields-v2

Conversation

@hogan-yuan
Copy link
Copy Markdown
Member

@hogan-yuan hogan-yuan commented May 11, 2026

Problem

AlertContext::enable() and AlertContext::disable() were two separate methods that:

  1. Sent only {id, enabled} — missing required fields (indicator_id, frequency, scope, state, value_map), causing invalid frequency:0 / invalid indicator id API errors
  2. Created an unnecessary implicit list() round-trip to look up the missing fields (with pagination risk)
  3. Were redundant — both do the same thing with just a boolean difference

Solution

Replace enable and disable with a single update(item, enabled) method:

  • Caller passes the AlertItem from list() directly — no extra round-trip, no pagination risk
  • enabled = true → enable; enabled = false → disable
  • Cleaner, consistent API across all language SDKs

Changes

File Change
rust/src/alert/context.rs enable + disableupdate(&AlertItem, bool)
rust/src/blocking/alert.rs blocking wrapper updated
python/src/alert/context.rs enable + disableupdate(AlertItem, bool)
nodejs/src/alert/context.rs enable + disableupdate(AlertItem, bool)
java/src/alert_context.rs alertContextEnable + alertContextDisablealertContextUpdate (reads enabled from JNI)
c/src/alert_context/context.rs lb_alert_context_enable + lb_alert_context_disablelb_alert_context_update
c/csrc/include/longbridge.h C header updated accordingly

Verification

All local CI checks pass:

  • cargo fmt --check
  • cargo clippy (all 5 packages) ✓
  • cargo test (99/99) ✓

🤖 Generated with Claude Code

@hogan-yuan hogan-yuan force-pushed the fix/alert-enable-disable-missing-fields-v2 branch 2 times, most recently from 4d5dc23 to 9939afc Compare May 13, 2026 07:58
@hogan-yuan hogan-yuan changed the title fix(alert): pass AlertItem to enable/disable across all language SDKs fix(alert): merge enable/disable into update across all language SDKs May 13, 2026
Problem: enable() and disable() sent only {id, enabled} to the API,
causing "invalid frequency:0" and "invalid indicator id" errors.

Solution: change the signature to accept an AlertItem (obtained from
list()) so all required fields are available without an extra round-trip.

Changes:
- rust/src/alert/context.rs: enable/disable take &AlertItem; add
  internal set_enabled() helper that builds the full request payload
- rust/src/blocking/alert.rs: blocking wrappers accept AlertItem by value
- python/src/alert/: add From<AlertItem> for lb::AlertItem; binding
  passes AlertItem to core
- nodejs/src/alert/: add From<AlertItem> for lb::AlertItem; binding
  passes AlertItem to core
- java/src/alert_context.rs: add read_alert_item() that reads each
  field from the Java object via JNI; no FromJValue needed
- c/src/alert_context/: lb_alert_context_enable/disable accept
  *const CAlertItem; add CAlertItem::to_alert_item() conversion

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@hogan-yuan hogan-yuan force-pushed the fix/alert-enable-disable-missing-fields-v2 branch from 9939afc to 2a2b5cb Compare May 13, 2026 08:38
- blocking/alert.rs: keep update() replacing enable/disable
- python/alert/types.rs: add manual FromPyObject impl for AlertItem
  (needed since skip_from_py_object prevents auto-derivation)
  and adopt skip_from_py_object for AlertSymbolGroup/AlertList from main
- c/csrc/include/longbridge.h: accept auto-merged version

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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