fix(prometheus): handle explicit null timeout in instant and range query invoke - #2401
fix(prometheus): handle explicit null timeout in instant and range query invoke#2401jasimalam wants to merge 1 commit into
Conversation
…ery invoke Signed-off-by: Jasim Alam <jasimalam211@gmail.com>
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. WalkthroughPrometheus instant and range query tools now replace falsy timeout values, including ChangesPrometheus timeout fallback
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The PR applies the configured timeout when query arguments explicitly contain null and adds coverage for both query paths. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Deploy Preview for holmes-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
What's wrong
When the LLM emits
"timeout": nullin the tool arguments,params.get("timeout", default_timeout)still returnsNonethe key exists so the default is never applied. The comparisonNone > max_timeoutthen raises:TypeError: '>' not supported between instances of 'NoneType' and 'int'
This surfaces to the operator as
Failed to connect to Prometheus, which is misleading since Prometheus connectivity is fine. The bug is present in both the instant query (ExecuteInstantQuery._invoke, line 1614) and range query (ExecuteRangeQuery._invoke, line 1868) paths.Fix
Changed
params.get("timeout", default_timeout)toparams.get("timeout") or default_timeoutin both paths so an explicitnullfalls through to the configured default.Tests
Added
TestNullTimeoutintests/plugins/toolsets/test_prometheus_unit.pywith two cases — one for instant query and one for range query — that patchdo_requestand assert the timeout passed downstream equalsDEFAULT_QUERY_TIMEOUT_SECONDSwhen"timeout": nullis in the params.Fixes #2376
Summary by CodeRabbit
Bug Fixes
0orNone.Tests