Conversation
WalkthroughThe PR adds a test output ignore rule, modifies the Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/WebServer.cpp (1)
529-537: Clamp normalizeddetection_ratio_thresholdto a valid range before save.After normalization, values outside
0..100are still possible. Clamping here makes the endpoint robust regardless of downstream setter behavior.♻️ Suggested patch
if (jsonObj.containsKey("detection_ratio_threshold")) { float threshold = jsonObj["detection_ratio_threshold"].as<float>(); // Accept legacy 0.0-1.0 ratio payloads as well as 0-100 percent. if (threshold > 0.0f && threshold <= 1.0f) { threshold *= 100.0f; } + if (threshold < 0.0f) + { + threshold = 0.0f; + } + else if (threshold > 100.0f) + { + threshold = 100.0f; + } settingsManager.setDetectionRatioThreshold(static_cast<int>(threshold + 0.5f)); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/WebServer.cpp` around lines 529 - 537, The code that reads "detection_ratio_threshold" normalizes values in WebServer.cpp but doesn't clamp them, so values outside 0..100 can be saved; after the normalization step for threshold (the local variable named threshold derived from jsonObj["detection_ratio_threshold"]) clamp threshold to the inclusive range 0.0f..100.0f before calling settingsManager.setDetectionRatioThreshold(static_cast<int>(threshold + 0.5f)); to ensure the setter always receives a valid percentage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/WebServer.cpp`:
- Around line 529-537: The code that reads "detection_ratio_threshold"
normalizes values in WebServer.cpp but doesn't clamp them, so values outside
0..100 can be saved; after the normalization step for threshold (the local
variable named threshold derived from jsonObj["detection_ratio_threshold"])
clamp threshold to the inclusive range 0.0f..100.0f before calling
settingsManager.setDetectionRatioThreshold(static_cast<int>(threshold + 0.5f));
to ensure the setter always receives a valid percentage.
Summary by CodeRabbit