{"record":{"id":"a25f61dfc38cdef5","repo":"slimtoolkit/slim","slug":"cannot-encode-stop-command-w","errorCode":null,"errorMessage":"cannot encode stop command: %w","messagePattern":"cannot encode stop command: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/standalone/control/stop.go","lineNumber":14,"sourceCode":"package control\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/slimtoolkit/slim/pkg/ipc/command\"\n\t\"github.com/slimtoolkit/slim/pkg/util/fsutil\"\n)\n\nfunc ExecuteStopTargetAppCommand(ctx context.Context, commandsFile string) error {\n\tmsg, err := command.Encode(&command.StopMonitor{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot encode stop command: %w\", err)\n\t}\n\n\tif err := fsutil.AppendToFile(getFIFOPath(commandsFile), msg, false); err != nil {\n\t\treturn fmt.Errorf(\"cannot append stop command to FIFO file: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/standalone/control/stop.go#L1-L23","documentation":"ExecuteStopTargetAppCommand encodes a command.StopMonitor{} message before appending it to the commands FIFO. This error wraps a failure of command.Encode, meaning the stop command could not be serialized.","triggerScenarios":"command.Encode failing for &command.StopMonitor{} — e.g. the encoder returns an error due to an unsupported/changed message format or an internal serialization failure.","commonSituations":"Version mismatch between the sensor binary and the code issuing the stop command (message schema changed); corrupted or incompatible command package.","solutions":["Inspect the wrapped error from command.Encode for the concrete serialization failure.","Ensure the client code and the slim sensor binary use matching versions of the command package/schema.","Rebuild both sides from the same source revision."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := control.ExecuteStopTargetAppCommand(ctx, commandsFile); err != nil {\n    if strings.Contains(err.Error(), \"cannot encode stop command\") {\n        log.Errorf(\"stop command encoding failed; check client/sensor version match: %v\", err)\n    }\n    return err\n}","preventionTips":["Build the control client and sensor from the same source revision.","Add a round-trip test encoding/decoding command.StopMonitor{} in CI.","Pin versions when distributing the sensor and its control tooling."],"tags":["serialization","ipc","control"],"backgroundTag":"message-encode-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}