Honor explicit inactive_threshold of 0 in KV watch - #991
Conversation
watch() treated inactive_threshold with a truthiness check, so an explicit 0 (disable the inactivity cleanup) was indistinguishable from None and got overridden with the 5 minute default. Check against None so 0 is passed through to the consumer instead of being clobbered.
|
Claude finished @caspervonb's task in 2m 2s —— View job PR Review
SummaryThe fix in Findings1. Related unfixed bug in # nats/src/nats/js/client.py:432
if inactive_threshold:
config.inactive_threshold = inactive_thresholdThis is the same truthiness-check pattern. If a caller uses if inactive_threshold is not None:
config.inactive_threshold = inactive_threshold2. Weak test assertion # test_js.py
assert info.config.inactive_threshold < 5 * 60This verifies the old bug (forced 300s) is gone, but not what value the server actually applied. Given the comment says 3. No correctness or security issues. The change is safe and the test covers the regression case. |
Mirror the KV watch fix in the ordered/watch consumer config path: the truthiness check silently dropped an explicit 0, so a caller asking to forward 0 was ignored. Assert against the config the client sends rather than the server round-trip, since the server rewrites 0 to its own minimum for ordered consumers. Also reword the KV comment to describe the forwarding accurately.
watch()used a truthiness check oninactive_threshold, so an explicit0(disable the inactivity cleanup) was indistinguishable fromNoneand got overridden with the 5 minute default. Check againstNone.Fixes #580.