slimtoolkit/slim · error
unknown command: %s
Error message
unknown command: %s
What it means
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.
Source
Thrown at pkg/app/sensor/app.go:325
cmd := control.Command(os.Args[2])
switch cmd {
case control.StopTargetAppCommand:
if err := control.ExecuteStopTargetAppCommand(ctx, *commandsFile); err != nil {
return fmt.Errorf("error stopping target app: %w", err)
}
case control.WaitForEventCommand:
if len(os.Args) < 4 {
return errors.New("missing event name")
}
if err := control.ExecuteWaitEvenCommand(ctx, eventsFilePath(), event.Type(os.Args[3])); err != nil {
return fmt.Errorf("error waiting for sensor event: %w", err)
}
default:
return fmt.Errorf("unknown command: %s", cmd)
}
return nil
}
View on GitHub (pinned to 81940d17fa)
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.
Example fix
// before sensor stoped-target-app // typo // after sensor stop-target-app // exact control.StopTargetAppCommand value
Defensive patterns
Strategy: validation
Validate before calling
valid := map[control.Command]bool{
control.StopTargetAppCommand: true,
control.WaitForEventCommand: true,
}
if !valid[control.Command(os.Args[2])] {
return fmt.Errorf("usage: sensor <%s|%s>", control.StopTargetAppCommand, control.WaitForEventCommand)
} Type guard
func isKnownCommand(s string) bool {
switch control.Command(s) {
case control.StopTargetAppCommand, control.WaitForEventCommand:
return true
}
return false
} Prevention
- 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
When it happens
Trigger: 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].
Common situations: 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.
Related errors
- unknown sensor mode
- missing command
- missing event name
- error stopping target app: %w
- error waiting for sensor event: %w
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/a132abf4fc397e21.
Report an issue: GitHub.