{"record":{"id":"a132abf4fc397e21","repo":"slimtoolkit/slim","slug":"unknown-command-s","errorCode":null,"errorMessage":"unknown command: %s","messagePattern":"unknown command: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/app.go","lineNumber":325,"sourceCode":"\n\tcmd := control.Command(os.Args[2])\n\n\tswitch cmd {\n\tcase control.StopTargetAppCommand:\n\t\tif err := control.ExecuteStopTargetAppCommand(ctx, *commandsFile); err != nil {\n\t\t\treturn fmt.Errorf(\"error stopping target app: %w\", err)\n\t\t}\n\n\tcase control.WaitForEventCommand:\n\t\tif len(os.Args) < 4 {\n\t\t\treturn errors.New(\"missing event name\")\n\t\t}\n\t\tif err := control.ExecuteWaitEvenCommand(ctx, eventsFilePath(), event.Type(os.Args[3])); err != nil {\n\t\t\treturn fmt.Errorf(\"error waiting for sensor event: %w\", err)\n\t\t}\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown command: %s\", cmd)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":307,"sourceCodeEnd":330,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/app.go#L307-L330","documentation":"runControlCommand switches on the control command parsed from os.Args[2]. If the value matches none of the known control commands (stop-target-app, wait-for-event, etc.), the default branch returns this error, aborting the sensor run with a message naming the unrecognized command.","triggerScenarios":"Invoking the sensor binary with an unknown or misspelled second argument, e.g. sensor stop-target (instead of the exact control.StopTargetAppCommand string) or passing an empty/garbage token in os.Args[2].","commonSituations":"Script/Makefile typos in the sensor invocation; version drift where an old script uses a command name removed from the control package; quoting bugs that pass the wrong argv slot as the command.","solutions":["Print/echo os.Args[2] and compare it exactly against the exported control command constants.","Fix the spelling in the calling script to match the control package constants.","Check the control package for the current list of valid commands after upgrading the sensor version.","Add argument validation with usage output before dispatching so bad commands fail early with help text."],"exampleFix":"// before\nsensor stoped-target-app   // typo\n// after\nsensor stop-target-app     // exact control.StopTargetAppCommand value","handlingStrategy":"validation","validationCode":"valid := map[control.Command]bool{\n    control.StopTargetAppCommand: true,\n    control.WaitForEventCommand:  true,\n}\nif !valid[control.Command(os.Args[2])] {\n    return fmt.Errorf(\"usage: sensor <%s|%s>\", control.StopTargetAppCommand, control.WaitForEventCommand)\n}","typeGuard":"func isKnownCommand(s string) bool {\n    switch control.Command(s) {\n    case control.StopTargetAppCommand, control.WaitForEventCommand:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Copy command names from the control package constants instead of typing them","Add a usage/help output listing valid commands on argument error","Keep launch scripts in sync when upgrading the sensor binary"],"tags":["cli","argument-validation","sensor"],"backgroundTag":"unknown-command","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}