Repository navigation
tasks: don't panic on a malformed sockets-monitor config - #1697
Open
NRGLine4Sec wants to merge 1 commit into
Open
NRGLine4Sec wants to merge 1 commit into
NRGLine4Sec wants to merge 1 commit into
Conversation
initConfig asserted cfg["state"].(float64) and the same for "proto",
"family" and "interval" with no type check. A task config missing a
field, or carrying one of the wrong JSON type, panicked the assertion
and took the whole daemon down (a TASK_START without "state" crashed
with "interface conversion: interface {} is nil, not float64").
Read each field with a checked conversion and return a config error
instead, which the caller already reports. Valid configs behave as
before; "interval" keeps its 5s default.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
socketsmonitor.initConfigread its fields with bare type assertions:cfg["interval"].(string),cfg["state"].(float64), and the same forprotoandfamily. The configuration is decoded JSON received from the GUI, so a config missing one of these fields, or carrying one of the wrong type, panicked the assertion and took the whole daemon down. ATASK_STARTfor the sockets monitor without astatefield crashes with:This reads each field with a checked conversion and returns a config error instead;
Newalready propagates that error to the caller, which reports it. Valid configurations behave exactly as before, andintervalkeeps its5sdefault.A unit test covers a valid config, a missing field, a wrong-typed field, the interval default, and a non-object config.
🤖 Generated with Claude Code